I have a problem with switching views. I'm using a simulator with xcode 4.2
Storyboard contains:
NavigationController
(initial view controller)UIViewController
which has relationship with the navigation controllerUIViewController
(paired with my custom class: ViewEntryImageController
) which hasn't got any relationship. Contains a button, a bottom toolbar with some toolbar button.User come into the UIViewController
, where he can see a ScrollView
and in ScrollView
some images.
Images has a gesture:
UITapGestureRecognizer *recognizer=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(openEntryImage)];
[image addGestureRecognizer:recognizer];
[recognizer release];
The openEntryImage function:
(IBAction)openEntryImage
{
ViewEntryImageController *controller=[[ViewEntryImageController alloc]initWithNibName:nil bundle:nil];
controller.modalTransitionStyle=UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:controller animated:YES];
[controller release];
}
When I try to tap the image, the openEntryImage
works as well (the effect is correct), but I don't see my ViewEntryImageController
view and my buttons, I'm only see a black window.
I try to put a NSLog line into the ViewEntryImageController
viewDidLoad
function, and it works, so what is the black window and where is my view controller?
When I try to use pushViewController
, on the new view I found a navigation toolbar with a back button, but no other controls.
I tried another version, I created a UIViewController
class, but now with a xib file. I used it instead of ViewEntryImageController
and it works. Why?
I want to use this controller in storyboard too.
Try it like this :
ViewEntryImageController *controller=[[ViewEntryImageController alloc]initWithNibName:@"ViewEntryImageController" bundle:nil];
If you don't use .nib names but rather use storyboards, it's a bit harder. Create a segue from the controller to the ViewEntryImageController controller by holding ctrl and dragging from one view to the other. Click this segue and give it an identifier.
Then use the [self performSegue:@"identifier"];
function to present the next view.