谁的视图不在窗口层次结构问题中 [英] Whose view is not in window hierarchy issue

查看:96
本文介绍了谁的视图不在窗口层次结构问题中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了一个navController,它在点击按钮后出现。但是,如果我点击按钮,我会收到以下错误:警告:尝试在< MyApp:0xadaa320>上显示< UINavigationController>:0xab5d9d0,其视图不在窗口层次结构中!

I've set up a navController, which appears after tapping a button. However, if I tap the button I get the error of: "Warning: Attempt to present <UINavigationController>: 0xab5d9d0 on <MyApp: 0xadaa320> whose view is not in the window hierarchy!"

有谁知道如何解决这个问题?我也尝试过Stackoverflow,但这不是我的解决方案。

Does anyone know how to solve this? I also tried something on Stackoverflow but it wasn't my solution.

这里是我打开导航控制器的代码:

Here my code for opening the navigationcontroller:

我不知道是否有人知道这个照相馆,但如果你不知道不,此处是项目。

I dont know if somebody know this photogallery but if you don't, here is the project.

我的代码(MyApp.m):

#import MyApp.h
...
//some stuff
- (void)launchGalleryView
{



    MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];

    // Set browser options.
    browser.wantsFullScreenLayout = YES;
    browser.displayActionButton = NO;


    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:browser];

    NSMutableArray *photos = [[NSMutableArray alloc] init];
    MWPhoto *photo;
    photo = [MWPhoto photoWithFilePath:[[NSBundle mainBundle] pathForResource:@"callculator" ofType:@"jpg"]];
    photo.caption = @"The calculator is soo beateful...";
    [photos addObject:photo];

    self.photos = photos;

    [self presentModalViewController:navController animated:NO];
}

提前致谢。

编辑:

它位于资源和编译源中,但在资源中您可以看到它是红色的(故事板)。也许是由此引起的?

it is in the recources and in the compile sources but in the resources you can see that it is red (the storyboard). Maybe it's caused by this?

第二个控制器.h:

@class MyApp;

@interface Second : UIViewController <MWPhotoBrowserDelegate> {

}



@property (nonatomic, retain) MyApp* vC;

@end

Secnond控制器.m:

#import "Second.h"
#import "MyApp.h"


@interface Second ()

@end

@implementation Second

@synthesize vC;
    //some stuff in here


//the action 
    - (IBAction)dothis:(id)sender {

        NSLog(@"launch the navcontroller");


        [self.vC launchGalleryView];

    }

MyApp.h:

#import "Second.h"


@interface myApp : UIViewController  <MWPhotoBrowserDelegate> {
    }

-(void)launchGalleryView;

NSArray *_photos;

新编辑:

I发现我必须在viewDidAppear中调用方法launchGalleryView但是如何在每次加载视图时都不调用navcontroller来执行此操作?有谁知道怎么做?

I found that I have to call the method "launchGalleryView" in the viewDidAppear but how can I do this without calling the navcontroller everytime the view loads? Does anyone know how to do this?

推荐答案

我检查了你的项目..无法解决正确的问题。 。

i checked your project.. wasn't able to sort out the proper issue..

但是我尝试了黑客并且它有效..

but i tried a hack and it worked..

[self presentModalViewController:navController animated:YES];

[[[[[UIApplication sharedApplication] delegate] window] rootViewController] presentModalViewController:navController animated:YES];

这篇关于谁的视图不在窗口层次结构问题中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆