【发布时间】:2015-07-31 02:45:15
【问题描述】:
我使用大小为 wAny 和 hAny 的 Xib 文件创建了一个 ViewController,并且我使用了自动布局和约束来适应 UI 所有设备和所有方向。
一切正常,但是当我在 iPhone 上运行应用程序时,导航栏的纵向模式标题不居中,而将其旋转到横向模式时,标题居中。
我使用以下代码来设置标题
self.title = @"Download Schedule";
已经尝试过: 我试图将较小字体大小的自定义 UILabel 设置为导航栏的标题视图,但我仍然将它放在左侧。
这是我的右键代码
//add right bar button for more options
UIView *navBarButtonsView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 44, 44)];
UIBarButtonItem *item0 = [UIBarButtonItem negativeSpacerWithWidth:5];
UIButton *moreButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)];
[moreButton setBackgroundImage:[UIImage imageNamed:@"ic_web"] forState:UIControlStateNormal];
[moreButton addTarget:self action:@selector(addNewSchedule) forControlEvents:UIControlEventTouchDown];
[navBarButtonsView addSubview:moreButton];
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithCustomView:navBarButtonsView];
self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:item0, backButton, nil];
【问题讨论】:
标签: ios objective-c iphone uinavigationbar uinavigationitem