【发布时间】:2017-03-22 06:57:00
【问题描述】:
我有一个 tableView 作为我的第一个视图。每个单元格都是可点击的,点击时,我使用 presentViewController 来显示带有新数据的当前视图。我没有导航栏,所以我不能使用导航控制器和推送。问题是每次我点击一个单元格时,它都会显示一个新视图(这很好),但是在按下后退按钮时,它只会后退一步,但我想让它进入第一个视图。我该怎么做?
print("clicked " + String(indexPath.row) )
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("playVideo") as! PlayVideoViewController
preferences.setValue( self.video[indexPath.row].id , forKey: "id" )
//self.dismissViewControllerAnimated(false, completion: nil)
self.presentViewController(vc, animated: true, completion: nil)
返回:
self.dismissViewControllerAnimated(true, completion: nil)
【问题讨论】:
-
如果你使用 UINavigationController,你可以通过使用 -pushViewController:animated: 方法推送它在导航控制器堆栈中显示“vc”,返回按钮将调用 -popToRootViewControllerAnimated: 导航控制器方法。
-
@IgorBidiniuc 我没有navigationController,所以我不能用它
-
那么为什么你不能使用它呢?你可以隐藏导航栏。
-
@IgorBidiniuc 谢谢,我不知道我可以隐藏导航栏。我想我可以使用它。
标签: ios swift uiviewcontroller presentviewcontroller