iOS 检测状态栏点击事件


 

 

当tableView.scrollsToTop=YES不管用时,可以使用以下方法实现点击状态栏使tableView滚动到顶部。

 

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    [super touchesBegan:touches withEvent:event];
    CGPoint location = [[[event allTouches] anyObject] locationInView:self.view];
    CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;

    if (CGRectContainsPoint(statusBarFrame, location)) {
        [UIView animateWithDuration:0.3f animations:^{
            self.tableView.contentOffset = CGPointMake(0, self.tableViewOriginalOffset);
            [self.tableView layoutIfNeeded];
        }];
    }
}

 

 

 

参考地址:http://stackoverflow.com/questions/3753097/how-to-detect-touches-in-status-bar

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM