我正在开发适用于 iPad 和 iPhone 的应用程序,我在导航栏中添加了多个栏项目,但我想添加不同的栏项目...在 iPad 的导航栏中,我只想添加 2 个项目权利,这已经在起作用。但我还想在 iPhone 导航栏的左侧添加 2 个其他按钮。但是通过我尝试的方式,我得到了相同的导航栏,相同的项目,关于如何向导航栏添加不同项目的任何想法。
这是我的代码:
UIBarButtonItem *refreshButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
target:self action: @selector(IpadReload:)];
UIImage *emailIcon = [UIImage imageNamed:@"emailicon.png"];
UIBarButtonItem *emailButton = [[UIBarButtonItem alloc] initWithImage:(emailIcon) style:UIBarButtonItemStylePlain target:self action:@selector(emailButtonTapped:)];
NSArray *rightButtonsArray = [[NSArray alloc] initWithObjects:refreshButton, emailButton, nil];
self.navigationItem.rightBarButtonItems = rightButtonsArray;
UIBarButtonItem *previousButton = [[UIBarButtonItem alloc] initWithTitle:@"Previous" style:UIBarButtonItemStylePlain target: self action: @selector(PreviousClicked:)];
UIImage *phoneIcon = [UIImage imageNamed:@"phoneicon.png"];
UIBarButtonItem *phoneButton = [[UIBarButtonItem alloc] initWithImage:(phoneIcon) style:UIBarButtonItemStylePlain target:self action:@selector(callPhone:)];
NSArray *leftButtonsArray = [[NSArray alloc] initWithObjects:previousButton, phoneButton, nil];
self.navigationItem.leftBarButtonItems = leftButtonsArray;