iPhoneアプリ作成(14) ステータスバーでタッチを検知する方法
iPhone の safari のように、ステータスバーに触れると先頭にジャンプできるようにするために、
ステータスバーでタッチを検知する方法を探し、あちこちめぐると下記のサイトをみつけた。
http://stackoverflow.com/questions/2470562/how-do-i-detect-touches-on-uistatusbar-iphone
- (void)viewDidLoad { [super viewDidLoad]; // required UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectZero]; scrollView.delegate = self; scrollView.contentSize = CGSizeMake(0.0f,1.0f); [scrollView setContentOffset:CGPointMake(0.0f,1.0f) animated:NO]; // optional scrollView.scrollsToTop = YES; // default is YES. [self.view addSubview:scrollView]; } - (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView { NSLog(@"Detect status bar is touched."); /* Your own code. */ return NO; }
テストしてみた結果、UIViewControllerではタッチを検知できたが、UITableViewControllerでは検知できない。
どうしてtebleViewでは動作しないのか、皆目わからん。
ちょっと放置しておこうかな...