3
我使用連接到UINavigationController
的UIPageViewController
來顯示兩個頁面,一個用戶表和一個聊天表。如何在UIPageViewController的導航欄上顯示按鈕?
我想實現以下:
兩個按鈕Users
和Chat
賴以,會出現相應的視圖控制器攻。我想要導航欄上的這些按鈕。
下面是我寫在頁面視圖控制器類
viewDidLoad()
let storyBoard = UIStoryboard(name: "Main", bundle: nil)
let vc1 = storyBoard.instantiateViewControllerWithIdentifier("users")
let vc2 = storyBoard.instantiateViewControllerWithIdentifier("chat")
vcArray = [vc1, vc2]
self.setViewControllers([vc1], direction: .Forward, animated: true, completion: nil)
let button1 = UIButton(frame: CGRectMake(0, 30, self.view.frame.width/2, 30))
let button2 = UIButton(frame: CGRectMake(self.view.frame.width/2+1, 30, self.view.frame.width/2, 30))
button1.setTitle("Users", forState: .Normal)
button2.setTitle("Chat", forState: .Normal)
self.navigationController?.navigationBar.topItem?.titleView?.addSubview(button1)
self.navigationController?.navigationBar.topItem?.titleView?.addSubview(button2)
不幸的是,所有按鈕都出現在導航欄的代碼。 事實上,我甚至不能爲導航欄分配標題。我怎樣才能解決這個問題?
感謝
感謝您的回覆。不幸的是,這並不能解決問題。我轉移到RKSwipeViewController的內置功能 –