MMProgressHUD icon indicating copy to clipboard operation
MMProgressHUD copied to clipboard

Allow skipping of confirmation while retaining cancel block

Open vincentjames501 opened this issue 12 years ago • 2 comments

First off I'd like to say this is an amazing project.

Is there anyway to skip the confirmation piece and go straight to success on user tap gesture?

My use case is simple. Show a 'Recording' HUD and then when the users taps the HUD it dismisses. It seems to me like there should a property such as dismisses on touch. Is there any way to do this with it's current implementation?

Thoughts?

vincentjames501 avatar Dec 13 '13 23:12 vincentjames501

I forgot to mention that something like this works, but it would be nice to be baked in.

...
self.dismissRecordingHUDRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(stopRecording)];
    [[MMProgressHUD sharedHUD].hud addGestureRecognizer:self.dismissRecordingHUDRecognizer];
...

- (void)stopRecording {
    [[MMProgressHUD sharedHUD].hud removeGestureRecognizer:self.dismissRecordingHUDRecognizer];
    [MMProgressHUD dismissWithSuccess:@"Succes"];
}

vincentjames501 avatar Dec 13 '13 23:12 vincentjames501

The most generic way to do this would be for MMProgressHUD to expose the tap gesture recognizer and allow you to hook into it yourself (just so long as you didn't specify a cancel block when you displayed MMProgressHUD):

[[MMProgressHUD sharedHUD] tapGestureRecognizer] addTarget:self
                                                    action:@selector(stopRecording:)];

...

- (void)stopRecording {
  UITapGestureRecognizer *tapGesture = [[[MMProgressHUD sharedHUD] tapGestureRecognizer];
  [tapGesture removeTarget:self action:@selector(stopRecording:)];

  [MMProgressHUD showWithStatus:@"Saving Recording..."];

  // Do stuff to save recording.
  [MMProgressHUD dismissWithSuccess:@"Success"];
}

I wouldn't want to add a specific property like skipConfirmation or requiresConfirmation in order to keep the implementation and internal states generic enough. If enough people ask for it then that's a different story.

larsacus avatar Jan 09 '14 23:01 larsacus