0

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 -

enter image description here

1 Answer 1

1

Use self.navigationItem.title to set the title.

Sign up to request clarification or add additional context in comments.

2 Comments

You should write this as a solution, not as a question.
No, but please write a solution in the Answers and questions in the Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.