I have use the Xcode 4.5.1 and use this conditions
#define IOS_OLDER_THAN_6 ( [ [ [ UIDevice currentDevice ] systemVersion ] floatValue ] < 6.0 )
#define IOS_NEWER_OR_EQUAL_TO_6 ( [ [ [ UIDevice currentDevice ] systemVersion ] floatValue ] >= 6.0 )
#ifdef IOS_OLDER_THAN_6
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
[image_signature setImage:[self resizeImage:image_signature.image]];
return (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
#endif
#ifdef IOS_NEWER_OR_EQUAL_TO_6
-(BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
[image_signature setImage:[self resizeImage:image_signature.image]];
return UIInterfaceOrientationMaskLandscapeLeft;
}
#endif
I have add the key in info.plist.
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
</array>
And set the support interface orientation
IF i have add the key in info.plist and set the support orientation and no use the below code , application is not work in ios 5.0
This code is work but i want to use small alternative concept....Please help me..
Thanks in advance!!
Your approach is not healthy. The preprocessor blocks will only get compiled if #ifdef statements are true. What you have done is to make the preprocessor statements depend on runtime parameters.
You can try removing all preprocessor blocks. Make your deployment target 5.0.
Edit: FYI, these methods are callback methods so they will get called by system if needed. iOS5 will call shouldAutorotateToInterfaceOrientation method likewise iOS6 will call supportedInterfaceOrientations and iOS6's rotation methods accordingly. So you should handle all your system differences on runtime, not compile-time, unless you are compiling two different versions of app for two different systems on purpose.
Thanks MR. basar...i solve my problem ...I explain How to solve my problem....
If you set orientation in your app In IOS 5 and IOs 6
then folllow the step
1) Go to project -> select support Interface Orientations
Example :- You want to select Landscape Left and Landscape Right .. See the image
2) When you select Orientations then automatically add the key in info.plist (check in info.plist ) if no add then you add the key in info.plist
Example:-
3) add the code in each viewcontroller
// For IOS 5
// For IOS 6
Note:-
1) No Need the condition (IOS Version) ...Because Both
shouldAutorotateToInterfaceOrientation (IOs 5
)supportedInterfaceOrientations (IOS 6)
are delegate and it's call runtime...(see basar answer).2) if you work only IOS 6 then no need the code. only work with step1 and step 2
There is another way - without setting allowed orientation:
Try this solution - it works on iOS 5 and iOS 6.
UINavigationController Force Rotate
Then, You can implement shouldRotate .. delegate methods, to allow it to rotate only between landscape orientations.
Good luck!
remove those preprocessors blocks and add this to support autorotations in both ios5 and ios6 we need to provide call backs in case of ios6....`[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
and we need to call
}
for ios5