gpt4 book ai didi

iphone - 将UIBarButtonItem添加到iPhone SDK上的UINavigationController

转载 作者:行者123 更新时间:2023-12-01 19:21:44 25 4
gpt4 key购买 nike

我想在UINavigationController上添加后退按钮,我正在尝试以下代码:

EGOPhotoViewController *photoController = [[EGOPhotoViewController alloc] initWithPhotoSource:source];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:photoController];
navController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
navController.modalPresentationStyle = UIModalPresentationFullScreen;
// UINavigationBar *my_bar;
//UINavigationItem *my_item=[[UINavigationItem alloc] initWithTitle:@"test"];
UIBarButtonItem* button = [[UIBarButtonItem alloc] initWithTitle: @"Back"
style: UIBarButtonItemStyleBordered
target: navController
action: @selector(onBack)];
//my_item.rightBarButtonItem = button;
[[navController navigationItem] setRightBarButtonItem:button];
self.title=@"Gallery";
[self presentModalViewController:navController animated:YES];

此代码输出如下:

代码未在UINavigationController中添加“后退按钮”。我正在将代码添加至UINavigationController上的“后退”按钮,我的代码有什么问题...!

请任何人帮我...!

谢谢..!

最佳答案

尝试从rootviewcontroller类(photoController)viewDidLoad方法添加UIBarButtonItem。

self.navigationItem.rightBarButtonItem =  [[UIBarButtonItem alloc] initWithTitle: @"Back"
style: UIBarButtonItemStyleBordered
target: navController
action: @selector(onBack)];

关于iphone - 将UIBarButtonItem添加到iPhone SDK上的UINavigationController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10105882/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com