简体   繁体   English

无法在导航栏上获得正确的栏按钮项目?

[英]Can't get the right bar button item on a navigation bar?

I'm trying to have a button on the right side of my navigation controller - after this works I'd like the button to be as near to invisible as possible while still working. 我正试图在我的导航控制器的右侧有一个按钮 - 在这个工作之后,我希望按钮尽可能接近隐形,同时还能正常工作。 Maybe setting to high transparency or changing the colour to the navigation bar colour (whatever is cheaper for memory). 也许设置为高透明度或将颜色更改为导航栏颜色(无论内存更便宜)。

First though I can't seem to get a visible or working button on the right side of my navigation bar: 首先,虽然我似乎无法在导航栏的右侧看到可见或工作按钮:

self.navigationController.navigationItem.rightBarButtonItem = 
[[UIBarButtonItem alloc] initWithTitle:@"coin" style:UIBarButtonItemStyleDone
target:self action:@selector(changeToInAppScene:)];

您必须分配给self.navigationItem.rightBarButtonItem (当前视图控制器的导航项),而不是self.navigationController.navigationItem.rightBarButtonItem

- (void)viewWillAppear:(BOOL)animated
{
    UIBarButtonItem *rightBar = [[UIBarButtonItem alloc]initWithTitle:@"Coin" style:UIBarButtonItemStylePlain target:self action:@selector(changeToInAppScene:)];
    self.navigationItem.rightBarButtonItem = rightBar;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM