开发者

iphone for Orientation [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

How to force a screen orientation in specific view controllers?

hello

I want to set the orientation in one particular view so how can i do that. andbody have example for that. i used the

-(void)onUIDeviceOrientationDidChangeNotification:(NSNotification*)notification{
    UIViewController *tvc = self.navigationController.topViewController;
    UIDeviceOrientation orientation = [[ UIDevice currentDevice ] orientati开发者_如何学Goon ];
    tabBarController.view.hidden = YES;
    // only switch if we need to (seem to get multiple notifications on device)
    if( orientation != [[ UIApplication sharedApplication ] statusBarOrientation ] ){
        if( [ tvc shouldAutorotateToInterfaceOrientation: orientation ] ){
            [ self rotateInterfaceToOrientation: orientation ];
        }
    }
}

but its done is whole application and i want to done only in one screen so please reply thank you


on a particula view controller put

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

this is for potrait for other u can do like wise


// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    // Over ride this method in your required view controller to display only in the necessary orientation
}


Add this method in your class

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    // Over ride this method in your required view controller to display only in the necessary orientation
     return YES;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜