【发布时间】:2010-06-03 17:53:53
【问题描述】:
我正在使用 UILabel 作为导航栏的 titleView(我正在制作简单的应用内网络浏览器)。它工作正常,除了当我展示一个模态视图控制器时,titleView 从导航栏的中心移动到最左边(在后退按钮下方)。我已经在 3.0 及更高版本中进行了测试。以下是相关代码:
- (void)viewDidLoad {
[super viewDidLoad];
// Title view label
CGRect labelFrame = CGRectMake(0.0, 0.0, 120.0, 36.0);
UILabel *label = [[[UILabel alloc] initWithFrame:labelFrame] autorelease];
label.font = [UIFont boldSystemFontOfSize:14];
label.numberOfLines = 2;
label.backgroundColor = [UIColor clearColor];
label.textAlignment = UITextAlignmentCenter;
label.textColor = [UIColor whiteColor];
label.shadowColor = [UIColor blackColor];
label.shadowOffset = CGSizeMake(0.0, -1.0);
label.lineBreakMode = UILineBreakModeMiddleTruncation;
self.navigationItem.titleView = label;
}
-(void)displayComposerSheet:(NSString*)mailto
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[self presentModalViewController:picker animated:YES];
[picker release];
}
截图:
知道为什么会这样吗?谢谢。
【问题讨论】:
标签: ios iphone cocoa-touch uinavigationbar