TIMEX
TIMEX

Reputation: 272164

How can I make an ActionSheet cell not dismiss when clicked?

I want one of the options to do nothing when clicked. It's basically a placeholder. It won't have a title, and it's just white.

func actionSheet(sheet: UIActionSheet, clickedButtonAtIndex buttonIndex: Int) {
    if sheet.tag == 1 {
        var title = sheet.buttonTitleAtIndex(buttonIndex)
        if title == Constants.EmptyTitleActionSheetItem{
               //do nothing. don't dismiss.
        }else{

               //something real was clicked. perform actions and continue dismissal
        }
    }
}

Upvotes: 2

Views: 584

Answers (3)

Atif Alvi
Atif Alvi

Reputation: 498

There a are 2 choices I see.

  1. As I mentioned in the comment above, I don't think it's possible to avoid dismissal. The alternative solution is that you can present the Action-Sheet again when the button where you need "don't dismiss" is tapped, with animate = FALSE.
  2. You can build your own actionSheet OR use a third-party open-source library.

Upvotes: 5

Paresh Navadiya
Paresh Navadiya

Reputation: 38249

Only option is to create a custom or use third party

Third party Action Sheet are given below:

JGActionSheet - A feature-rich and modern action sheet for iOS.

AHKActionSheet - An alternative to the UIActionSheet with a block-based API and a customizable look. Inspired by the Spotify app. It looks a lot better live than on the GIF (because compression).

Upvotes: 0

rajesh
rajesh

Reputation: 41

put return statement in that if block.

if title == Constants.EmptyTitleActionSheetItem{
  //do nothing. don't dismiss.
    return;
    }

Upvotes: -1

Related Questions