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.
- (void)performLayout
{
[super performLayout];
myScrubView.frame = self.bounds;
__block BOOL reload = NO;
UIView (^addSubView)(UIView *) = ^ (UIView *subview) {
subview.alpha = 0.0;
if (subview != nil)
subview.alpha = 1.0;
else
{
subview = [[UIView alloc] init];
[myScrubView addSubview:subview];
reload = YES;
}
subview.frame = myScrubView.bounds;
return subview;
};
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
UIView *subView = addSubView(orientation == UIInterfaceOrientationPortrait ? myPortraitView : myLandscapeView);
if (orientation == UIInterfaceOrientationPortrait) {
myPortraitView = subView;
} else {
myLandscapeView = subView;
}
if (reload)
[self reloadData];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment