gpt4 book ai didi

iphone - 以编程方式创建的窗口出现但不响应触摸事件

转载 作者:行者123 更新时间:2023-12-03 19:10:55 25 4
gpt4 key购买 nike

我正在创建没有 MainWindow nib 的应用程序,更新到新的 SDK 后,我的应用程序完全崩溃了。在 main.m 的 main() 函数中我有:

int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");

这是 AppDelegate.m 中 application:didFinishLaunchingWithOptions: 的相关部分

window = [[UIWindow alloc] init];

tabBarController = [[UITabBarController alloc] init];

UINavigationController *nav = ...;
UITableViewController *table = ...;

tabBarController.viewControllers = [NSArray arrayWithObjects:nav, table, nil];

[window addSubview:tabBarController.view];
[window makeKeyAndVisible];

应用程序启动时,选项卡栏可见,第一个选项卡中的 View 也是可见的。但是,所有触摸事件要么没有被注册,要么没有被传递到窗口本身。我对 UIWindow 进行了子类化,并将 window 设置为它的一个实例。在这个子类中,我重写了 sendEvent: 方法,以便在调用该方法时记录到控制台。什么也没有出现。我做错了什么?

最佳答案

嗯,我明白了。希望这对某人有帮助。这些是我的应用程序中的前几行:didFinishLaunchingWithOptions: method:

window = [[UIWindow alloc] init];
window.screen = [UIScreen mainScreen]; // this fixes the problem

关于iphone - 以编程方式创建的窗口出现但不响应触摸事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4373729/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com