【问题标题】:Switch NavigationItem title with segmented control使用分段控件切换 NavigationItem 标题
【发布时间】:2015-09-15 16:15:45
【问题描述】:

我有一个导航项和一个导航栏。导航项具有标题(和按钮),导航栏(在导航项下方)具有分段控件。

当按下分段控件的一侧(objective-c)时,如何使导航项上的标题发生变化?

这是 .m 文件中的代码

   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];
        }

这就是它的样子 -

【问题讨论】:

    标签: ios objective-c uisegmentedcontrol uinavigationitem


    【解决方案1】:

    使用self.navigationItem.title 设置标题。

    【讨论】:

    • 你应该把它写成一个解决方案,而不是一个问题。
    • 否,但请在评论中的答案和问题中写下解决方案
    猜你喜欢
    • 1970-01-01
    • 2022-01-03
    • 2013-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-13
    • 1970-01-01
    相关资源
    最近更新 更多