views:

40

answers:

1

i have use this code but it is Private API ,apple also reject!

[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];

if i rotate my device in Landscape then open my Application it will present as Portrait mode, i need to rotate my device to another orientation then it will update.

how to update it to correct orientation when call UIViewController?

A: 

You should use the follow code at your UIViewController class:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

if u need to update orientation at runtime then u have to return other constant

return (interfaceOrientation == UIInterfaceOrientationPortrait);

Yakov
thanks Yakov, this code will call when the device have change orientation, it can answer my problem, that is when push my View it will present incorrect orientation. so if i force it with setOrientation: it will be reject by apple.
RAGOpoR
So... Also you would try to add 'Initial interface orientation' property into info.plist. for ex: you can set value 'Landscape (right home button)' or 'Portrait (top home button)'.
Yakov