码迷,mamicode.com
首页 > 移动开发 > 详细

iOS 检测状态栏点击事件

时间:2016-08-20 00:09:18      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:

 

 

当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];
        }];
    }
}

 

iOS 检测状态栏点击事件

标签:

原文地址:http://www.cnblogs.com/ficow/p/5789390.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!