Skip to content

Instantly share code, notes, and snippets.

@dannygreg
Forked from hatfinch/gist:1385399
Created November 22, 2011 12:08
Show Gist options
  • Save dannygreg/1385518 to your computer and use it in GitHub Desktop.
Save dannygreg/1385518 to your computer and use it in GitHub Desktop.
// 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