简体   繁体   中英

Present view controller displays black screen

I'm trying to present a view using code in Objective C, but all it comes up with is the title bar and a black screen. This is the code I am using:

MoreByUserViewController *morebyuser = [[MoreByUserViewController alloc] initWithOwnerId:self.ImageOwner];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:morebyuser];
[self presentModalViewController:navController animated:YES];

I am calling this from the startup view (hereby referred to as View 1) and the view I'm trying to load will be View 2.

I don't have View 2 included as #include or @class in View 1, do I need to?

Like Ryan and Dustin said, you probably are not loading the nib in that initWithOwnerID method. I would recommend initializing the view first, and then setting the ownerID as a property after.

MoreByUserViewController *morebyuser = [[MoreByUserViewController alloc] initWithNibName:@"MoreByUserViewController" bundle:nil];
[morebyuser setOwnerID:self.ImageOwner];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:morebyuser];
[morebyuser release];
[self presentModalViewController:navController animated:YES];
[navController release];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM