ios - How to set device orientation only landscape? -


i'm writing simple app under macos using xcode. want app in landscape mode always. set landscape orientation in project properties. when add button window.subview, button doesn't appear in landscape position.

i have appdelegate class. i've changed function: - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions

i've added:

self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]]; self.window.backgroundcolor = [uicolor purplecolor]; [self.window makekeyandvisible];  uibutton *button = [uibutton buttonwithtype:uibuttontyperoundedrect]; [button setbackgroundcolor:[uicolor whitecolor]]; [button setframe:cgrectmake([[uiscreen mainscreen] bounds].size.width/2 - 50, [[uiscreen mainscreen] bounds].size.height/2,                             100, 100)]; [button settitle:@"button" forstate:uicontrolstatenormal]; [self.window addsubview:button]; 

enter image description here

update: added [self.window settransform:cgaffinetransformmakerotation(-m_pi/2)];

and got: enter image description here

select target project , make sure have choose following landscape mode:

enter image description here


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -