Skip to content

Instantly share code, notes, and snippets.

@tanb
Created April 24, 2014 07:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tanb/11245010 to your computer and use it in GitHub Desktop.
Save tanb/11245010 to your computer and use it in GitHub Desktop.
// MyViews.xib に複数のViewをいれました
NSArray *nibContents = [[NSBundle mainBundle] loadNibNamed:@"MyViews" owner:nil options:nil];
// RestorationIDに適当な名前をつけておいて取り出しました
__block UIView *targetView = nil;
[nibContents enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) {
if ([view.restorationIdentifier isEqualToString:@"MyView"]) {
*stop = YES;
targetView = (UIView *)view;
}
}]; // targetViewは"MyView"というRestorationIDをつけたview
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment