[英]Is it possible to set the UIAccessibilityFrame for an UI control (eg UIButton) from xib file
[英]a UIButton defined in a XIB file is not instantiated
我創建了一個具有XIB文件並包含UIButton
視圖控制器。 我分配並初始化控制器,然后將視圖添加到超級視圖:
- (void)viewDidLoad
{
[super viewDidLoad];
self.vc = [[MyViewController alloc]init];
[self.view addSubview:self.vc.view];
CGRect frame;
frame.size.height = 200;
frame.size.width = 200;
frame.origin.x = 100;
frame.origin.y = 100;
self.vc.view.frame = frame;
[vc setText:@"123"];
}
當我運行此命令時,未顯示UIButton
。 當我調試它,並將斷點放在控制器的viewDidLoad
或viewDidAppear
, UIButton
始終未被實例化(內存地址00000000);
可能是什么問題?
您的MyViewController
應該使用XIB文件初始化:
...
self.vc = [[MyViewController alloc] @"MyViewController" bundle:nil];
...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.