iphone for Orientation [duplicate]
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;
}
精彩评论