当我将视图控制器推送到占屏幕一半的导航控制器时,由于某种原因,以前的视图控制器标题超出了范围。这仅发生在 iOS 5 而不是 iOS 6 中。知道为什么会发生这种情况或我们如何解决它吗?
问问题
235 次
1 回答
3
您可以像这样设置导航栏标题:-
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.navigationItem.leftBarButtonItem = self.editButtonItem;
UIBarButtonItem *addButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertNewObject:)] autorelease];
self.navigationItem.rightBarButtonItem = addButton;
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0.0, 0.0, 320.0, 44.0)];
[label setBackgroundColor:[UIColor clearColor]];
[label setNumberOfLines:0];
[label setTextColor:[UIColor whiteColor]];
[label setTextAlignment:UITextAlignmentCenter];
[label setFont:[UIFont systemFontOfSize:12]];
NSString *str =@"1234567890 1234567890 1234567890 1234567890 1234567890 123456";
[label setText:str];
self.navigationItem.titleView = label;
}
于 2012-10-27T05:04:47.413 回答