在呈现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];
}
非常感谢帮助。
答案 0 :(得分:0)
当您的[self presentViewController:animated:completion:]
实例不属于窗口层次结构时,您尝试在UserTableViewController
内展示(UserViewController
)UserViewController
,例如在导航堆栈上(已被推送或呈现)。