我的MainWindow.Xib中有2个UIView 一个是RootViewController视图的出口,另一个UIView是我希望从RootViewController的源代码使用tag(123)访问。 如果第二个UIView是第一个视图的子视图,我知道我可以使用
[self.view viewWithTag:123];
但是当我希望被访问的UIView不是当前视图的子视图时,我不知道如何处理这种情况。
欢迎任何评论
由于
InterDev中
答案 0 :(得分:0)
tag
特定于UIView
层次结构(请参阅UIView的viewWithTag:
上的返回值)。由于两个单独的视图之间没有层次结构,因此无法使用它。
相反,执行phix23建议并在IBOutlet
中为您的第二个视图添加RootViewController
,即:
<强> RootViewController.h 强>
@interface RootViewController : UIViewController {
// ...
}
// @synthesize in RootViewController.m (don't forget to dealloc)
@property (nonatomic, retain) IBOutlet UIView *secondView;
然后将其挂钩到您的XIB文件中。