Reputation: 3
I have been looking for a way to fix an issue I've been having for days but after many google searches and searches here I am still unable to fix it. I am very new to iOS programming but took a short 4 week "crash course" and learned a few things.
So currently I have three view controllers set up and want to switch between each one using buttons so that if a user is at the first page they can go to either the second or third and from that page they can go back to either page they want.
This is what I have in the first view controller:
#import <UIKit/UIKit.h>
#import "Galleries.h"
#import "JotForm.h"
@interface MainView : UIViewController
@property (strong, nonatomic) IBOutlet UIButton *galleryButton;
@end
Then in the implementation file I have this to handle the switching to the new view.
- (IBAction)galleryButton:(id)sender {
Galleries *gallery = [[Galleries alloc]initWithNibName:@"Galleries" bundle:nil];
[self.navigationController pushViewController:gallery animated:YES];
}
As of right now when I run the program it starts but when I click the gallery button it does nothing. How do I get it to switch to the next view? I have not used a navigation controller because I want to have the three buttons at the top of the app in each view and couldn't figure out how to do that with a navigation controller. Essentially I don't want any back buttons to be used when switching from page to page.
Thanks for any help anyone may be able to provide.
Upvotes: 0
Views: 64
Reputation: 535222
when I click the gallery button it does nothing ... I have not used a navigation controller
Well, there's your problem. You are sending a message to self.navigationController
, but it is nil (because, as you say, you don't have one) so nothing happens.
If you don't want a navigation controller, then I would suggest using presentViewController:...
; you can't push without a navigation controller.
Upvotes: 1