Reputation:
I put on my .xib file a navigation bar and a Bar Button Item.
I created an action for my button , i connected it and the action looks like this :
- (IBAction)AddAlert:(id)sender {
self.addReminderViewController =[[AddReminderViewController alloc]initWithNibName:@"AddReminderViewController" bundle:nil];
[self.navigationController pushViewController:addReminderViewController animated:YES];
}
where AddReminderViewController
is the controller i want to navigate to.
My ViewController.h looks like this :
#import <UIKit/UIKit.h>
@class AddReminderViewController;
@interface ViewController : UIViewController <UITableViewDelegate , UITableViewDataSource>
@property (strong, nonatomic) AddReminderViewController *addReminderViewController;
@property (strong,nonatomic) NSArray *listData;
- (IBAction)AddAlert:(id)sender;
@end
where i declare the @class AddreminderViewController
so that i can navigate there , and i synthesize the property on the .m file.
However when i press the button nothing happens. It doesnt crash! It just doesnt navigate me anywhere. Shall i make any changes to the AppDelegate? What am i missing here?
Upvotes: 0
Views: 175
Reputation: 12671
As you are using self.addReminderViewController
for initializing the controller but later you are ading without using self, Using the self
makes sure the object retain count is set correctly.
In your code
[self.navigationController pushViewController:addReminderViewController animated:YES];
try changing the above line and add self with addReminderViewController
, it might solve your issue
[self.navigationController pushViewController:self.addReminderViewController animated:YES];
Upvotes: 1