Guest User

Untitled

a guest
Jan 17th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. MyOtherViewController *movc = [[MyOtherViewController alloc] init];
  2. [self.view addSubview:movc.view];
  3.  
  4. UIView *newView = [[NSBundle mainBundle] loadNibNamed:@"MyNewXib" owner:self options:nil];
  5.  
  6. // assign it to a property
  7. @property (strong, non atomic) UIView *viewFromXib;
  8. @sythesize viewFromXib=_viewFromXib;
  9.  
  10. self.viewFromXib = newView;
  11.  
  12. // add it to your hierarchy
  13. self.viewFromXib.frame = CGRectMake( /* this will start out 0,0 the size from the xib */ );
  14. [self.view addSubview:self.viewFromXib];
  15.  
  16. // add gesture recognizer
  17. UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)];
  18. [self.viewFromXib addGestureRecognizer:tapGR];
Add Comment
Please, Sign In to add comment