UIScrollview in a UIViewController
I'm trying to modify the Apple PageControl example (iPhone version) so that UIScrollView is displayed via a UIViewController instead of the UIWindow that the exampl开发者_开发技巧e uses.
Following the example, the AppDelegate.m initiates the phoneContentController like so:
[[NSBundle mainBundle] loadNibNamed:nibTitle owner:self options:nil];
[self.window addSubview:self.contentController.view];
[window makeKeyAndVisible];
When I try to initiate the same type of content controller like so:
myController = [[MyController alloc] initWithNibName:@"MyController" bundle:nil];
myController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:myController animated:YES];
I just get a blank screen.
Everything in the modification - well not everything; I can't get the silly thing working - maps to the PageControl.
Anyone have a working example? The scroll view will not be the first panel displayed in this application. By the time the user gets to the ScrollView, it's several screens down.
I can't believe I can't Google an example of this behavior. It seems so basic.
Wearily, Steve
Just in case anyone else lifts that example and hits the same error with which I was grappling. The solution to this problem was to remove the following method from the PhoneContentController.m class:
- (UIView *)view
{
return self.scrollView;
}
The AppDelegate was adding the view to the window from the contentController (PhoneContentController in this case) so it needed an accessor to the view property when it made the window visible.
[self.window addSubview:self.contentController.view];
[window makeKeyAndVisible];
精彩评论