UIActionSheet с табличным представлением - PullRequest
2 голосов
/ 22 марта 2011

HEllo, может ли кто-нибудь подсказать мне следующее

  • Я хочу добавить ActionSheet с настраиваемым изображением.
  • В ActionSheet я хочу разместить табличное представление для данных.
  • Две кнопки (отмена и готово)

Спасибо ....

Ответы [ 2 ]

7 голосов
/ 02 мая 2013

проверьте мой ответ.Я использую этот код для отображения UITableView в листе действий.

В .h файле

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

В .m файле

-(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)];
}
5 голосов
/ 22 марта 2011

Вам не нужно добавлять таблицу в UIActionSheet, просто добавьте 7 - 8 кнопок в UIActionSheet, и она автоматически будет размещена в виде таблицы.

Смотрите прикрепленный скриншот .. enter image description here

...