谁的视图不在窗口层次结构中?

时间:2013-09-10 04:08:01

标签: ios

我从另一个uiviewcontroller(WelcomeScreen)调用uiviewControllor(ExchangeToday)。 但错误是:

2013-09-10 11:57:24.005 exchangerate [3234:c07]警告:尝试在窗口层次结构中显示其视图!

我的代码是:

@interface ExchangeToday : UIViewController <UIScrollViewDelegate, UITableViewDelegate, UITableViewDataSource>

UIViewController *second = [[ExchangeToday alloc] initWithNibName:@"ExchangeToday_iPhone" bundle:nil];
second.modalPresentationStyle = UIModalPresentationFormSheet;
second.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:second animated:YES];

如何解决?

2 个答案:

答案 0 :(得分:0)

您在创建“UIViewController”或“ExchangeToday”?

我认为你的第一行应该是:

      ExchangeToday *second = [[ExchangeToday alloc] initWit hNibName:@"ExchangeToday_iPhone" bundle:nil];

答案 1 :(得分:0)

我遇到了同样的错误,在我的情况下我正在打电话

[self presentModalViewController:second animated:YES];

在调用视图(self)完成呈现之前。换句话说,你不能在viewDidLoad或viewWillAppear中调用presentModalViewController,它应该在viewDidAppear中或者在视图加载完成后很好。