gpt4 book ai didi

iphone - viewDidAppear 中的调用方法

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:17:16 25 4
gpt4 key购买 nike

我设置了一个 void如果用户触摸按钮,则从另一个类调用该方法。但是,我收到“其 View 不在窗口层次结构中”的错误,然后我发现了这个:whose view is not in the window hierarchy .我只想调用下面的方法,但我收到了这个错误,它没有向我显示 navigatoncontroller .它说Warning: Attempt to present <UINavigationController: 0xae34f10> on <ViewController: 0xae1f200> whose view is not in the window hierarchy!我不知道这是否可以从 viewDidAppear 调用方法或者从某处它只有在之前在另一个 View 上点击按钮时才有效。如果我调用NSLog在方法中它向我展示了 NSLog在输出中。仅呈现 navController似乎不起作用。如果有人可以帮助我,我会很高兴。

我的方法:

- (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:@"calculator" ofType:@"jpg"]];
photo.caption = @"The calculator is soo beauteful...";
[photos addObject:photo];

self.photos = photos;

[self presentModalViewController:navController animated:YES];

}

只是忘了说:MWPhotoprowser 是一个实际上无关紧要的类。

提前致谢。

最佳答案

错误消息非常清楚——您正试图显示此类中的 Controller ,但具有您按下的按钮的类是其 View 位于 View 层次结构中的类。您要么需要使用按钮从类里面展示它,要么返回到这个类,但是您正在这样做,然后在 viewDidAppear 之后调用它。

关于iphone - viewDidAppear 中的调用方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13897467/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com