【发布时间】:2014-04-25 01:29:32
【问题描述】:
我有一个基于选项卡的应用程序,我正在尝试更改 UINavigationBar 的标题,当单击一个按钮时会加载一个新的 Uiview 但没有显示!
我这样创建栏:
navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, screenWidth, 60)];
navBar.barTintColor = [UIColor colorWithRed:0.082 green:0.118 blue:0.141 alpha:1.0];
navBar.tintColor = [UIColor whiteColor];
navBar.translucent = NO;
[self.view addSubview:navBar];
然后在方法中我尝试改变:
UIView *sendASongView = [[UIView alloc] init];
[sendASongView setFrame: CGRectMake(0, 60, screenWidth, screenHeight-110)];
[sendASongView setBackgroundColor:[UIColor whiteColor]];
[self.view addSubview:sendASongView];
navBar.topItem.title = @"Send";
【问题讨论】:
-
您应该创建一个
UINavigationController并将其用作您的viewController 的容器。然后你可以设置标题self.title = @"Send"。 -
@KudoCC 你能告诉我它是怎么做的吗?我对 ios 很陌生,谢谢!
-
如何制作和添加
UINavigationController到您的应用程序实际上取决于您应用程序的其余部分。如果您在情节提要中创建标签栏控制器,您应该只添加一个导航控制器作为标签之一。 -
您使用的是 Storyboard 还是 xib 或两者都不使用?
-
@KudoCC none,以编程方式做所有事情
标签: ios objective-c uiview uiviewcontroller uinavigationcontroller