您好,我需要设置右侧的按钮,在导航栏,编程,以便如果我按下按钮,我将执行一些行动。我已经通过编程创建了导航栏;
navBar=[[UINavigationBar alloc]initWithFrame:CGRectMake(0,0,320,44) ];
类似地,我需要在这个导航栏的右侧添加按钮。为此我使用了,
1.
UIView* container = [[UIView alloc] init];
// create a button and add it to the container
UIButton* button = [[UIButton alloc] i
我有一个UIViewController,在UINavigationController中嵌入了一个UITableView,它启动了一个UITabBarController。显示导航栏,包括后退按钮,我可以从UITabBarController中以编程方式更改导航项的标题。
但是我不能将UIBarButtonItem添加到UITabBarController的子控制器中。无论是在故事板中,还是以编程方式。
我还试图将子控制器嵌入到UINavigationController中,但这只是添加了第二个导航条。如何从UIBarButtonItem的子级添加UITabBarController s
我已经跟踪了我在网上找到的信息,并设法显示了按钮,但当我点击它时,什么也没有发生。我是iOS编程新手,我不确定我是否做错了什么。
UIImage *backImage = [UIImage imageNamed:@"backIcon.PNG"];
// create the button and assign the image to the button
UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
[backButton setImage:backImage forState:UIC
我正在以编程方式创建一个UINavigationController,并将我的ViewController添加到其中:
// wrap in a navigation controller
let navigationController = UINavigationController(rootViewController: myViewController)
self.present(navigationController, animated: true, completion: nil)
然后将图像添加到导航项中:
let backButton: UIBarButtonItem = U