小编dfw*_*ang的帖子

iOS13:如何检测状态栏的单击事件?

在我的appDelegate中,我重写touchesBegan以检测何时单击状态栏:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    [super touchesBegan:touches withEvent:event];

    CGPoint location = [[[event allTouches] anyObject] locationInView:kWindow];
    CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;

    if (CGRectContainsPoint(statusBarFrame, location)) {
        ///do something 
    }
}
Run Code Online (Sandbox Code Playgroud)

在iOS 13之前,此功能有效;在iOS 13上则没有。该方法从不执行。我怎样才能解决这个问题?

objective-c ios13

9
推荐指数
1
解决办法
820
查看次数

标签 统计

ios13 ×1

objective-c ×1