有人可以指导我完成所有步骤,因为我感到有些卡住和迷路

上一个问题:iOS - set UIButton target and action from its super class

现在,我试图获得一个更笼统的想法-我对此很陌生

非常感谢帮助

最佳答案

如果要从视图控制器本身内部访问关联的UIViewController的UIView,则只需使用self.view。要从UIViewController类的外部访问同一UIView,可以使用该类的实例名称以及.view属性。例如:

//SomeClass.m
- (void)accessVCView
{
   //With a Nib File:
   MyUIViewController *aVCObject = [[MyUIViewController alloc] initWithNibName:@"MyNib" bundle:nil];
   //Or with a Storyboard:
   MyUIViewController *aVCObject = [[UIStoryboard storyboardWithName:@"myStoryboard" bundle:nil] instantiateViewControllerWithIdentifier:@"MyViewController"];

   UIView *myUIViewControllerView = aVCObject.view;
}

07-27 14:03