经历了针对这个问题的每一个stackoverflow解决方案之后,它仍然令人沮丧地不适合我.
//UIBarButtonItem declaration UIBarButtonItem* button1 = [[UIBarButtonItem alloc] initWithTitle:@"Button Text" style:UIBarButtonItemStyleBordered target:self action:@selector(myAction)]; //method 1 [self setToolbarItems:[NSArray arrayWithObjects: button1,nil] animated:YES]; //method 2 [self.navigationController.toolbar setItems:[NSArray arrayWithObject:button1]]; //method 3 self.navigationController.toolbarItems = [NSArray arrayWithObject:button1]; //displaying toolbar [self.navigationController setToolbarHidden:NO];
上述方法都不适用于在工具栏上显示按钮 – 我得到的只是一个空白工具栏.有什么明显的东西我在这里不见了吗?
解决方法
移动
//UIBarButtonItem declaration UIBarButtonItem* button1 = [[UIBarButtonItem alloc] initWithTitle:@"Button Text" style:UIBarButtonItemStyleBordered target:self action:@selector(myAction)]; //method 1 [self setToolbarItems:[NSArray arrayWithObjects: button1,nil] animated:YES]; //displaying toolbar [self.navigationController setToolbarHidden:NO];
to viewDidAppear:(BOOL)animated这是UINavigationController获取它管理的UIViewController工具栏项的点.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。