Swift TableViewController is in Landscape

南笙酒味 提交于 2019-12-25 03:26:37

问题


I have a tableViewController that when a row is tapped on goes to a url using a KINWebBrowserViewController. The tableViewController should only be in portrait but the KINWebBrowserViewController can be landscape or portrait. When I go back to the tableViewController in landscape the tableViewController is also in landscape. How can I stop this?

The code for orientation:

class CustomNC: UINavigationController {

    override func supportedInterfaceOrientations() -> Int {
        if visibleViewController is KINWebBrowserViewController { return Int(UIInterfaceOrientationMask.All.rawValue) }
        return Int(UIInterfaceOrientationMask.Portrait.rawValue)}
}

The code for didSelectRowAtIndexPath:

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

    let linkItem = linkLabels[indexPath.row] as String

    let webBrowser = KINWebBrowserViewController()
    let url = NSURL(string: linkItem)
    webBrowser.actionButtonHidden = true
    webBrowser.loadURL(url)

    self.navigationController?.pushViewController(webBrowser, animated: true)
}

Any help?

来源:https://stackoverflow.com/questions/29389468/swift-tableviewcontroller-is-in-landscape

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!