objective-ccydiatheos

Double tap gesture on status bar


I have made my very first app (simple re-spring) with Theos, currently it works by tapping in the icon but I wish to redo it without an icon (as a tweak) and have the phone respiring when I double tap on the task bar.

Question is: how do I add a double tap gesture on the status/task bar?

Thanks.


Solution

  • There're several ways. You can use custom events or capture touches in your app delegate class like there

    Ok, your answer is much simpler. To be useful here the -(BOOL)scrollViewShouldScrollToTop: method implementation for your task.

    - (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView
    {
      tapIndex++; // class member
      if(tapIndex==2)
      {
        [self statusBarDoubleTapped];
        tapIndex=0;
      }
      else
      { 
        NSTimeInterval interval = 1; // one second wait for the second tap
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(interval * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
               if(tapIndex==1) // one second since the only status bar tap
                 tapIndex=0;
            });
      }
      return NO; // don't scroll to top
    }