문제

In my Phone App I need an ActionSheet where I have multiple button sections and the possibility to select one button of each section. An accept the whole with an Ok button.

First I have a method where I open the ActionSheet:

-(void)showActionSheet{
    UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles: nil];

    for(int i = 0; i < [selectionArray count]; i++){
        ObjektGroup *groupArray = [selectionArray objectAtIndex:i];
        for(int j = 0; j < [groupArray count]; j++){
            [sheet addButtonWithTitle:nameofbuttonbla];
        }
        [sheet addButtonWithTitle:@"------------------"];
    }
    [sheet addButtonWithTitle:@"OK"];
    sheet.cancelButtonIndex = sheet.numberOfButtons-1;
    [sheet showInView:self.view];  
}

As you can see, I add the Buttons dynamicly. That works fine, but the section devider ([sheet addButtonWithTitle:@"------------------"];) is not the final solution that I want. So is there a possibility to devide the groups like a grouped tableView? + I want only select one Button per section.

Another Problem is when following Method gets called:

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{}

The Actionsheet dismisses automaticly. I want to avoid that too.

Any ideas?

도움이 되었습니까?

해결책

You cannot do this with a UIActionSheet unfortunately as it only allows you to have one section and particularly it is meant to be dismissed after a single click.

As Apple doesn't allow UIActionSheet subclassing, you should look into building a customised solution using a UITableView.

다른 팁

I created a custom action sheet which has the ability of displaying multiple sections and you can completely customize the buttons or display your custom content view! You will be able to configure multiple selection! Have fun: https://github.com/JonasGessner/JGActionSheet

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top