Reputation: 9698
I have a custom UIView that I use to display synchronization in my device, but it won't rotate with the device when the orientation changes. Everything else rotates just fine, is there something I am missing to ensure my subclassed uiview will rotate?
Upvotes: 0
Views: 731
Reputation: 454
You can follow any of the following methods,
1-Create a class to subclass the UIView and override the shouldAutorotate in .m(implementation file). Now include this custom UIView class in your viewController to create objects.
2-Creating category for the UIView class
NOTE:- if your building app to support iOS6 then don't forget to include the methods which apply for your requirement
>>>>>- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
>>>>- (BOOL)shouldAutorotate;
>>>>- (NSUInteger)supportedInterfaceOrientations;
>>>>- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation;
Example For Category:-
@interface UIView (Additions)
@end
@implementation UIView (Additions)
- (BOOL)shouldAutorotate{
return YES;
}
@end
Upvotes: 0
Reputation: 29094
Programmatically:
- (BOOL)shouldAutorotate{
return YES;
}
add this. Hope this helps..
Or go to your Target Settings and click the directions you want it to rotate, but this will affect all your viewcontrollers.
Upvotes: 1