I have one navigationitem and one navigationbar. The navigation item has the title (and button) and navigationbar (below the navigationitem) has a segmented control.
How do I make it so the title changes on the navigationitem when one side of the segmented control is pressed (objective-c)?
Here's the code from the .m file
if (segmentController.selectedSegmentIndex == 0) {
UIWebView *webview6=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
NSString *url6=@"http://apple.com";
NSURL *nsurl6=[NSURL URLWithString:url6];
NSURLRequest *nsrequest6=[NSURLRequest requestWithURL:nsurl6];
[webview6 loadRequest:nsrequest6];
webview6.scrollView.bounces = NO;
[self.view addSubview:webview6];
[self.view bringSubviewToFront: navbar2];
}
if (segmentController.selectedSegmentIndex == 1) {
UIWebView *webview7=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
NSString *url7=@"http://yahoo.com";
NSURL *nsurl7=[NSURL URLWithString:url7];
NSURLRequest *nsrequest7=[NSURLRequest requestWithURL:nsurl7];
[webview7 loadRequest:nsrequest7];
webview7.scrollView.bounces = NO;
[self.view addSubview:webview7];
[self.view bringSubviewToFront: navbar2];
}
Here's what it looks like -
Use self.navigationItem.title
to set the title.