How to detect the orientation of the subview of a class added on other class view?
I want to detect the orientation(i.e Landscape or portrait) of the subview of the class which I have added on other class view controller. In other words, I have added a subview of the class viewcontroller to the other cl开发者_StackOverflowass view controller. and now I want to detect the orientation of that view.
How can I do this?
Try:
subViewController.interfaceOrientation
To have a clean interface, you could create a category class for UIApplication and return interfaceOrientation on these lines:
- (UIInterfaceOrientation)my_interfaceOrientation {
return [objc_getAssociatedObject(self, &interfaceOrientationKey) intValue];
}
Sometimes viewController.interfaceOrientation
doesn't seem to work quite well, you probably should better go with [[UIApplication sharedApplication] statusBarOrientation]
assuming that you don't do any "dirty" hacks on the user interface!
精彩评论