我不知道为什么下面的代码不工作:添加两个按钮rightBarButtonItems不工作
UIBarButtonItem *newButton = [[UIBarButtonItem alloc] initWithTitle:@"New" style:UIBarButtonItemStyleBordered target:self action:@selector(newClicked:)];
UIBarButtonItem *shareButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(share:)];
self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:newButton, shareButton, nil];
它只导航栏,而不是“shareButton”按钮,显示“newButton”的UIBarButtonItem。
我只是复制并粘贴您的代码在我的应用程序,它的工作原理应该如此。 任何方式尝试通过重命名您的对象,例如newButton,shareButton –
是不是'新'一个保留字? – igrek
@igrek:只有在C++ – user102008