Search code examples
iphoneuitableviewuiactionsheet

UIAtionSheet with UITableView


I need some suggestions about UIActionSheet. In my case I have created an ActionSheet in which I am displaying the UITableView with some data.

UIActionSheet *asheet = [[UIActionSheet alloc] init];
[asheet showInView:self.view]; 
[asheet setFrame:CGRectMake(0, 250, 320, 320)];


CustomView *innerView = [[CustomView alloc] initWithNibName:@"CustomView" bundle:nil];
innerView.view.frame = CGRectMake(0, 10, 320, 210);

[asheet addSubview:innerView.view];

the CustomView contains the table . Data is displaying properly, it displays exact 3 rows, now I want some similar functionality like :
(1) when I click on any row, the selected row should come at center.
(2) and where should I add buttons (done , cancel) in CustomView or in ActionSheet ?
(3) and how I get the selected row when I click on Done button?

any suggestions ?

Thanks..


Solution

  • (1)

    when I click on any row, the selected row should come at center.

    Kindly provide me with more details on this issue i can't get it right.

    (2)

    and where should I add buttons (done , cancel) in CustomView or in ActionSheet ?

    Add them in the UIActionSheet:

     UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:@"Title" delegate:self     cancelButtonTitle:@"Cancel Button" destructiveButtonTitle:@"Destructive Button"     otherButtonTitles:@"Other Button 1", @"Other Button 2", nil];
     popupQuery.actionSheetStyle = UIActionSheetStyleBlackOpaque;
     [popupQuery showInView:self.view];
     [popupQuery release];
    

    (3)

    get the selected row when I click on Done button?

    NSIndexPath *indexPath = [MyTableView indexPathForSelectedRow]