0

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?

Nathan Schafer
  • 273
  • 4
  • 15
  • Put a print() statement in your custom supportedInterfaceOrientations() method. When is the method called? What value is it returning? If you rotate the phone after the table has fully reappeared, does it print something every rotation? – emrys57 Apr 01 '15 at 11:28
  • Can you force the orientation for the tableviewcontroller to portrait, Would this be of any help? - http://stackoverflow.com/questions/26357162/how-to-force-view-controller-orientation-in-ios-8 – rshankar Apr 01 '15 at 11:30
  • The method is called when ever the view rotates. Every rotation works but as said when returning in landscape the table is in landscape. – Nathan Schafer Apr 01 '15 at 11:39
  • Everything is working because I forced the tableview to go to portrait but I get this message: Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted. – Nathan Schafer Apr 01 '15 at 12:03
  • That is likely to be a completely separate problem, perhaps the timing of how you handle the segues. Try http://stackoverflow.com/questions/5425775/what-to-do-about-finishing-up-a-navigation-transition-in-an-unexpected-state-n or http://stackoverflow.com/questions/19518856/uinavigationcontroller-corrupted-navigation-bar-issue – emrys57 Apr 01 '15 at 12:42

0 Answers0