ios - How to find view controller of screen -
i have seen following code allows screen orientation of device:
if(uiinterfaceorientationisportrait(viewcontroller.interfaceorientation)) { //do portrait work } else if(uiinterfaceorientationislandscape(viewcontroller.interfaceorientation)){ //do landscape work }
the problem not sure substitute "viewcontroller" placeholder code. worth noting making keyboard app not sure if can use same view controllers might work other circumstances. controller can use tell orientation of screen?
you can in 2 ways.
uiinterfaceorientation orientation = [[uiapplication sharedapplication] statusbarorientation]; if (orientation == uiinterfaceorientationportrait || orientation == uiinterfaceorientationportraitupsidedown) { //portrait } if (orientation == uiinterfaceorientationlandscaperight || orientation == uiinterfaceorientationlandscapeleft) { //landscape }
or
if (uideviceorientationislandscape([uidevice currentdevice].orientation)) { //landscape } else { //portrait }
Comments
Post a Comment