有人可以引导我完成这些步骤吗,因为我感到有点卡住和迷失
上一个问题:iOS - set UIButton target and action from its super class
现在我正在尝试获得一个更一般的想法 - 我对此很陌生
非常感谢您的帮助
最佳答案
如果您希望从 View Controller 本身内部访问关联的 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;
}
关于iOS 如何从 UIViewController 访问 UIView 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17305874/