-
-
Save dannygreg/1385518 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In the class continuation or private category | |
{ | |
UIView *_portraitView; | |
UIView *_landscapeView; | |
} | |
@property (nonatomic, readonly) UIView *portraitView; | |
@property (nonatomic, readonly) UIView *landscapeView; | |
- (UIView *)subViewForOritentation:(UIInterfaceOrientation)orientation; | |
//In the main @implementation | |
- (UIView *)subViewForOritentation:(UIInterfaceOrientation)orientation | |
{ | |
return (orientation == UIInterfaceOrientationPortrait ? self.portraitView : self.landscapeView); | |
} | |
- (UIView *)portraitView | |
{ | |
if (_portraitView == nil) { | |
_portraitView = [[UIView alloc] init]; | |
//Any setup could go here or a common method if it can be abstracted | |
} | |
return _portraitView; | |
} | |
- (UIView *)landscapeView | |
{ | |
if (_landscapeView == nil) { | |
_landscapeView = [[UIView alloc] init]; | |
//Any setup could go here or a common method if it can be abstracted | |
} | |
return _landscapeView; | |
} | |
- (void)performLayout | |
{ | |
[super performLayout]; | |
myScrubView.frame = self.bounds; | |
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; | |
UIView *subview = [self subViewForOritentation:orientation]; | |
subview.alpha = 1.0; | |
[[[myScrubView subviews] lastObject] removeFromSuperView]; | |
[myScrubView addSubView:subview]; | |
subview.frame = myScrubView.bounds; | |
[self reloadData]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment