简体   繁体   English

iOS扩展UIWindow禁用了根视图控制器?

[英]iOS Extending UIWindow disabled the root view controller?

Team, 球队,

I have extended the UIWindow , this made my landing view controller ( rootViewController ) disabled ie, I could not able to interact with it. 我扩展了UIWindow ,这使我的着陆视图控制器( rootViewController )被禁用,即,我无法与其进行交互。

EBaseUIWindow is the class that has the UIWindow as a super class. EBaseUIWindow是将UIWindow作为超类的类。 When I replace the EBaseUIWindow with UIWindow i could able to interact with the rootViewController . 当我用UIWindow替换EBaseUIWindow ,我可以与rootViewController进行交互。

What would be the reason? 请问是什么原因?

    self.window = [[EBaseUIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] ;
    self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] ;
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    return YES;

Please suggest? 请提出建议?

Working after my below edit in my code: 在我的代码中进行下面的编辑之后,工作:

I had a sendEvent method overridden in my EBaseUIWindow. 我在sendEvent重写了sendEvent方法。 In that when I added the below line it started to work. 这样,当我添加以下行时,它开始工作。

[super sendEvent:event];

Thanks to Daij-Djan for the clue. 感谢Daij-Djan的线索。

without seeing any code of your custom class it's kinda.. guesswork.. there could be many reasons. 没有看到您的自定义类的任何代码,这有点..猜测..可能有很多原因。

BUT

in a way it comes down to 'your window class (or a view or recognizer it adds) consuming the events before they can reach the rootViewController view. 在某种程度上,它取决于您的窗口类(或它添加的视图或识别器)在事件到达rootViewController视图之前就对其进行了消耗。

identify places you deal with touches (events in general) and comment them out to see what's causing the issue 确定与您接触的地方(一般事件)并注释掉,以查看引起问题的原因

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM