xcode - Swift Allow landscape in KINWebBrowserViewController view -
i have table , each 1 assigned link. when row tapped link opens in kinwebbrowserviewcontroller view. don't want table allow landscape want web browser allow it. how can it?
some code:
let linkitem = linklabels[indexpath.row] string let webbrowser = kinwebbrowserviewcontroller() let url = nsurl(string: linkitem) webbrowser.actionbuttonhidden = true webbrowser.loadurl(url) self.navigationcontroller?.pushviewcontroller(webbrowser, animated: true)
all suggestions welcomed. :)
in general - deployment info section of project in xcode, tick permitted orientations screen in app.
ios calls supportedinterfaceorientations
method in rootmost uiviewcontroller visible on screen. if vc covers whole screen, earlier vcs (further towards root viewcontroller) not have method called.
if webbrowser
vc covers whole screen, put method in that:
override func supportedinterfaceorientations() -> int { return int(uiinterfaceorientationmask.all.rawvalue) }
if webbrowser
not cover whole screen, , navigationcontroller
still showing navigation bar, method not called, , 1 in navigationcontroller
called instead. so, subclass uinavigationcontroller
:
class customnc:uinavigationcontroller { override func supportedinterfaceorientations() -> int { if visibleviewcontroller kinwebbrowserviewcontroller { return int(uiinterfaceorientationmask.all.rawvalue) } return int(uiinterfaceorientationmask.portrait.rawvalue) } }
and declare uinavigationcontroller customnc
instead. haven't tested code, may have typos, technique working me now.
more explanation: customnc
new, cleverer uinavigationcontroller
going invent. can put code in swift file in project. existing uinavigationcontroller
, except changes behaviour on rotation. want inherit behaviour of uinavigationcontroller, , override rotation bit. bit inheriting:
class customnc:uinavigationcontroller {
and bit overriding:
override func supportedinterfaceorientations() -> int {
and need tell xcode root viewcontroller customnc
rather plain uinavigationcontroller
. if you've built project storyboard, can click uinavigationcontroller
select it, change class uinavigationcontroller
customnc
in identity inspector
tab @ top right of xcode.
Comments
Post a Comment