尝试显示其视图不在窗口层次结构中

时间:2015-02-19 21:31:45

标签: ios xcode

在呈现UITableViewController时,我遇到以下问题。

List[12426:444700] Warning: Attempt to present <UserTableViewController: 0x7fe4ba5d8e50> on <UserViewController: 0x7fe4ba5b6db0> whose view is not in the window hierarchy!

这是我的代码部分

@implementation UserTableViewController
@synthesize users;
- (void)viewDidLoad {


// UserTableViewController
//  Create Fetch Request in viewDidLoad
AppDelegate *appDelegate = [[UIApplication sharedApplication]delegate];
//Create NSManagedObjectContext instance

NSManagedObjectContext *context = [appDelegate managedObjectContext];
NSEntityDescription  *entity = [NSEntityDescription entityForName:@"User" inManagedObjectContext:context];
NSFetchRequest *request = [[NSFetchRequest alloc]init];
[request setEntity:entity];
[request setReturnsObjectsAsFaults:NO];
NSError *error;
NSArray *array = [[context executeFetchRequest:request error:&error]mutableCopy];
//setting users with array of fetched objects
[self setUsers:array];
NSLog(@"firstName is %@",array);
//[self presentViewController:UserTableViewController animated:YES completion:nil];

}

非常感谢帮助。

1 个答案:

答案 0 :(得分:0)

当您的[self presentViewController:animated:completion:]实例不属于窗口层次结构时,您尝试在UserTableViewController内展示(UserViewControllerUserViewController,例如在导航堆栈上(已被推送或呈现)。