0

So, I'd like to receive touches from the status bar anywhere, any view, from the app. Well actually only specific views, like home screens and root view controllers say from a view of a tab view controller.

So my goal is to: hold down the status bar to dismiss the current view, like a back button.

The reason why I'm using this approach as a back button is because the app I am making is a utility, like fully functional apps within one app. Therefore I do not want to use up space on the navbar item to display a back button.

Other fissures would be nice, like swipe left/right or double tap, but mostly holding down. I've seen alternatives like using a UIScrollView and use the - scrollsToTop method. Hmm not what I am looking for.

ErickES7
  • 558
  • 6
  • 16

1 Answers1

0

Hope this can help you.

When you tap the top area, which has 44 height, the event would be triggered.

- (void)viewDidLoad{
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(navigationBack:)];
    [self.view addGestureRecognizer:tapGesture];
}



- (void)navigationBack:(UITapGestureRecognizer *)tapGesture {
    CGPoint p = [tapGesture locationInView:self.view];
    if (CGRectContainsPoint(CGRectMake(0, 0, self.view.frame.size.width, 44), p)) {
        NSLog(@"this where you put you navigation back event");
    }
}
ronan
  • 1,611
  • 13
  • 20