Here Code:
#pragma mark callNotification
#pragma mark - orientationWillChange
[self performSelector:@selector(changeOrientationsNotification)];
Keep Coding... :)
/********************************* Notification For Orientation ***************************************/
#pragma mark - Orientation Notification#pragma mark callNotification
-(void)changeOrientationsNotification{
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(orientationWillChange:)
name: UIApplicationWillChangeStatusBarOrientationNotification
object: nil];
}
- (void)orientationWillChange: (NSNotification *) note
{
UIInterfaceOrientation orientation = [[[note userInfo] objectForKey: UIApplicationStatusBarOrientationUserInfoKey] integerValue];
if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight){
[self shouldAutorotateToInterfaceOrientation:orientation];
//NSLog(@"Landscape");
}else {
[self shouldAutorotateToInterfaceOrientation:orientation];
//NSLog(@"Portrait");
}
}
/*********************************Orienation closed***************************************/
#pragma mark - Orientation Code For iOS6
/************** ORIENTATION CODE FOR IOS 6 START **************************/
-(BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight){
[self shouldAutorotateToInterfaceOrientation:orientation];
//NSLog(@"Landscape");
}else {
[self shouldAutorotateToInterfaceOrientation:orientation];
//NSLog(@"Portrait");
}
return UIInterfaceOrientationMaskAll;
}
/************** ORIENTATION CODE FOR IOS 6 END **************************/
Calling Procedure :
[self performSelector:@selector(changeOrientationsNotification)];
Keep Coding... :)
Comments
Post a Comment