import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = UIColor.blackColor()
let btn = UIButton(frame:CGRectMake(0, 0, self.view.frame.size.width/2, 50))
btn.setTitle("点击测试", forState: UIControlState.Normal)
btn.center = self.view.center
btn.addTarget(self, action:#selector(self.testNavTab), forControlEvents: UIControlEvents.TouchDown)
view.addSubview(btn)
}
func testNavTab(){
let homevi = homeview()
//self.navigationController?.pushViewController(homevi, animated: true)
self.presentViewController(homevi, animated: true, completion: nil)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
以上是全部代码,如果用 presentViewController 就可以正常跳转( homeview 是一个空白页面),但是 pushViewController 就没有任何反应...
1
lion9527 2016-10-01 15:47:41 +08:00
你这个 ViewController 没有 navigationController 吧
|
2
ldp940622 2016-10-01 16:04:06 +08:00 via iPhone
self.navigationController 是不是 nil 了
|
4
timelessg 2016-10-01 18:18:52 +08:00 via Android
模态出来的肯定不会有 nav ,需要套一个 nav
|
6
heat OP 搞定了谢谢各位
|
7
paradoxs 2016-10-01 20:24:23 +08:00
push 是有 navigation 套着的时候才能用的.
在 storyboard 里面点 editor 然后 embed 然后点 navigation 可以嵌入一个. |
8
xiubin 2016-10-02 10:44:21 +08:00 via iPhone
楼主是打算入行还是偶尔学习下? iOS 新手不好找工作啊
|