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