gpt4 book ai didi

iphone - iPhone SDK 中导航标题未正确显示

转载 作者:行者123 更新时间:2023-11-29 04:13:23 25 4
gpt4 key购买 nike

enter image description here

正如您所看到的,导航标题位于两个按钮下方。

两个左/右按钮被添加到导航栏的 subview 。如何设置导航标题宽度?尽管看起来像...

我的代码如下:

self.navigationItem.titleView.frame=CGRectMake(0, 0, 20, 40);
[[self navigationItem]setTitleView:bigLabel];

最佳答案

如果您的UILable太长,您可以在iphone`中设置导航栏标题,但在ipad中您可以使用相同的逻辑:-



enter image description here



 - (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;

}

希望它能帮助你..:)

关于iphone - iPhone SDK 中导航标题未正确显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14050345/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com