iOS 状态栏点击事件
生活随笔
收集整理的這篇文章主要介紹了
iOS 状态栏点击事件
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
iOS應用中,點擊狀態欄會使得滾動視圖回滾到頂部,但如果當前視圖控制器中包含多個滾動視圖就會失效。
這里我們可以通過以下的方法獲取狀態欄的點擊事件。
方法一:AppDelegate.m
#pragma mark - Status Bar Touch Eventstatic NSString * const kStatusBarTappedNotification = @"statusBarTappedNotification";- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {[super touchesBegan:touches withEvent:event];CGPoint touchLocation = [[[event allTouches] anyObject] locationInView:self.window];CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;if (CGRectContainsPoint(statusBarFrame, touchLocation)){[self statusBarTouchedAction];} }- (void)statusBarTouchedAction {[[NSNotificationCenter defaultCenter] postNotificationName:kStatusBarTappedNotification object:nil]; }總結
以上是生活随笔為你收集整理的iOS 状态栏点击事件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 小说朗读器更新内容
- 下一篇: c4d导入大模型以及给建筑上贴图笔记