UIActionSheet with table view

hello can anyone direct me to the following

  • I want to add an ActionSheet with image customization.
  • In ActionSheet, I want to place a table view for data.
  • Two buttons (cancel and execute)

Thank....

+3
source share
2 answers

You do not need to add a table to the UIActionSheet, just add 7-8 buttons to the UIActionSheet and it will be automatically placed in the table.

See attached screenshot .. enter image description here

+5
source

check my answer. I use this code to display a UITableView in an action table.

In the .h file

@property (strong, nonatomic) IBOutlet UITableView *tableView;

In the .m file

-(void)addTableViewInActionSheet
{
   UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil
                                              delegate:nil
                                     cancelButtonTitle:nil
                                destructiveButtonTitle:nil
                                     otherButtonTitles:nil];

    [actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];


    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 50, 320, 210)];
    _tableView.dataSource = self;
    _tableView.delegate = self;
    [actionSheet addSubview:_tableView];

    UISegmentedControl *doneButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Done"]];
    doneButton.momentary = YES;
    doneButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);
    doneButton.segmentedControlStyle = UISegmentedControlStyleBar;
    doneButton.tintColor = DEFAULT_COLOR;
    [doneButton addTarget:self action:@selector(doneBtnClicked:) forControlEvents:UIControlEventValueChanged];
    [actionSheet addSubview:doneButton];

    UISegmentedControl *cancelButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Cancel"]];
    cancelButton.momentary = YES;
    cancelButton.frame = CGRectMake(10, 7.0f, 60.0f, 30.0f);
    cancelButton.segmentedControlStyle = UISegmentedControlStyleBar;
    cancelButton.tintColor = [UIColor blackColor];
    [cancelButton addTarget:self action:@selector(cancelBtnClicked:) forControlEvents:UIControlEventValueChanged];
    [actionSheet addSubview:cancelButton];


    [actionSheet showInView:self.view];
    [actionSheet setBounds:CGRectMake(0, 0, 320, 485)];
}
+7
source

All Articles