Reputation: 2026
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?
Upvotes: 1
Views: 3061
Reputation: 360
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];
Upvotes: 1