UIActionSheet – also dismiss when click other area

- (void)filterButtonTouched:(id)sender {
    //disable click while loading
    if (_model && _model.isLoading)
        return;
    
    if (_searchModel && _searchModel.isLoading)
        return;
    //dismiss
if (_sheetForFilter.isVisible) {
        [_sheetForFilter dismissWithClickedButtonIndex:0 animated:NO];
        return;
    }
    
    _sheetForFilter = [[UIActionSheet alloc]init];
    _sheetForFilter.delegate = self;
    _sheetForFilter.title = nil;
    for (NSString* option in _filterOptionTitles)
        [_sheetForFilter addButtonWithTitle:option];
    
    if (_indexOfFilterOption >= 0)
        _sheetForFilter.destructiveButtonIndex = _indexOfFilterOption;
        _sheetForFilter.cancelButtonIndex = [_sheetForFilter addButtonWithTitle:cancelStringForActionSheet()];     [_sheetForFilter showFromRect:[(UIButton*)sender frame] inView:self.view animated:YES];   //    [_sheetForFilter showInView:self.view];   }
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s