以编程方式向UINavigationController添加UIButton
问题描述:
在Interface Builder中,您可以将UIButton拖动到rightButtonItem和leftButtonItem之间的导航控制器的中心。以编程方式向UINavigationController添加UIButton
我想这样做以编程方式,因为我不加载xib。
我想:
[self.navigationItem addSubview:myButton] // no luck
[self.navigationController.navigationBar addSubview:myButton] //no luck
感谢
答
设置UINavigationItem
你想要的按钮出现与视图控制器的titleView
。
[myAddedViewController.navigationItem setTitleView:myButton]
感谢它的工作! – joec 2010-10-11 11:00:48