按钮在 XIB 文件中不起作用
嘿,我已经将 uiviewcontroller 的视图加载到 AppDelegate 文件的主窗口中。如果我通过加载 nib 名称(并动态创建 UIViewController)来做到这一点,则 xib 文件中的按钮会正确触发。如果我这样做,按钮将处于非活动状态。
很高兴提供更多信息,只是不确定提供哪些信息。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
launchScreen = [[LaunchScreen alloc] initWithNibName:nil bundle:nil];
[launchScreen.view setUserInteractionEnabled:YES];
[window addSubview:[launchScreen view]];
[window makeKeyAndVisible];
return YES;
}
Heya, I have loaded a uiviewcontroller's view into the main window in the AppDelegate file. If i do it by loading a nib name (and create the UIViewController on the fly), the buttons in the xib file fire properly. If i do it like this, the buttons are inactive.
Happy to give more information, just unsure which info to give.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
launchScreen = [[LaunchScreen alloc] initWithNibName:nil bundle:nil];
[launchScreen.view setUserInteractionEnabled:YES];
[window addSubview:[launchScreen view]];
[window makeKeyAndVisible];
return YES;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我似乎找到了罪魁祸首,主 xib 文件中有一个 ViewController 覆盖在按钮之上,阻止它们被使用。
Ok, I seem to have found the culprit, there was a ViewController in the main xib file that was being overlayed ontop of the buttons stopping them from being used.