I am using the following code to achieve a navigation bar in my app. (my app was crashing when I used a push segue so I need a modal segue meaning the nav bar is hidden after the modal segue is called)
UINavigationBar *navbar = [[UINavigationBar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
//do something like background color, title, etc you self
[self.view addSubview:navbar];
Does any one know any methods I can use with the above code to achieve back button functionality in the nav bar??
Use below code to add back button on left side of navigation bar.Add UIBarButtonItem on Navigation bar.
UIBarButtonItem *backButton = [[UIBarButtonItem alloc]
initWithTitle:@"Back"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(backBtnClicked:)];
self.navigationItem.leftBarButtonItem = backButton;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With