
这是在按下添加按钮时创建新视图的代码. (我做了一个有效的添加按钮,它拉起了导航栏)
- (IBAction)addbuttonpressed:(ID)sender { AddDrinkVIEwController *addVIEwController = [self.storyboard instantiateVIEwControllerWithIDentifIEr:@"DetailSecond"]; UINavigationController *addNavController = [[UINavigationController alloc] initWithRootVIEwController:addVIEwController]; [self presentModalVIEwController:addNavController animated:YES]; NSLog(@"Add button pressed!"); 这是addvIEwcontroller实现文件中的代码:
- (voID)vIEwDIDLoad{ [super vIEwDIDLoad]; self.navigationItem.leftbarbuttonItem = [[UIbarbuttonItem alloc] initWithbarbuttonSystemItem:UIbarbuttonSystemItemCancel target:self action:@selector(cancel:)]; self.navigationItem.rightbarbuttonItem = [[UIbarbuttonItem alloc] initWithbarbuttonSystemItem:UIbarbuttonSystemItemSave target:self action:@selector(save:)];}- (IBAction)save:(ID)sender { NSLog(@"Save pressed"); [self dismissModalVIEwControllerAnimated:YES];}- (IBAction)cancel:(ID)sender{ NSLog(@"Cancel pressed"); [self dismissModalVIEwControllerAnimated:YES];} 我已将addvIEw中的标头导入到根控制器中,所以我认为这不是问题,你们中的任何人都会看到任何错误吗?
解决方法 只需改变线条[self presentModalVIEwController:addNavController animated:YES];
至
[self presentVIEwController:navigationController animated:YES completion:nil];
并看到魔术.我也测试了代码
总结以上是内存溢出为你收集整理的objective-c – xcode添加按钮到导航栏全部内容,希望文章能够帮你解决objective-c – xcode添加按钮到导航栏所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)