tim*_*216 2 iphone xcode uiwindow uiapplication ios
我试图在iPhone的UIStatusBar上检测到任何触摸,但它无法正常工作.我已经尝试了子类化UIApplication和UIWindow来访问它但仍然没有
小智 5
根据汤姆的回答,我写了代码.它运作良好.
- (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;
}
Run Code Online (Sandbox Code Playgroud)