2011-03-22 63 views
3

您好, 任何一個可以指導我以下UIActionSheet與表視圖

  • 我要添加與自定義圖像的ActionSheet。
  • 在ActionSheet中,我想爲數據放置一個表視圖。
  • 兩個按鍵(取消&完成)

感謝....

+2

您是否嘗試過創建的tableview和兩個按鈕,設置它們的幀,然後在actionsheet做addSubview?您可能還需要繼承它並重寫它的drawRect方法。但我想你會有更多的運氣讓自己的觀點在你想要的時候進入或退出。我甚至不會開始考慮HIG對此的影響...... – 2011-03-22 06:14:12

+0

你能告訴我如何顯示錶視圖作爲操作表意味着表視圖應該像操作表一樣出現? – Maulik 2011-03-22 08:13:40

回答

5

你並不需要在UIActionSheet添加表只加7 - 8按鈕UIActionSheet,它會自動地放置在表。

見附件截圖.. enter image description here

+0

沒有找到任何鏈接! – Maulik 2011-03-22 06:32:15

+0

截圖本身就是答案。看到圖像與「刪除,按鈕7,按鈕8,按鈕9 ....」 – Saurabh 2011-03-22 06:33:30

7

檢查我的答案。我正在使用此代碼在動作表中顯示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)]; 
} 
+0

感謝您的答案,但其近2年...:P – Maulik 2013-05-02 06:47:32

+0

對不起,但我已經開始iOS開發從過去6個月,今天見過你帖子。所以回答了。 :) – iKT 2013-05-02 07:11:23

+1

不用擔心。它總是o.k.回答舊的(甚至已經回答的)問題 - 您的答案可能適用於任何其他類似問題的用戶。 – 2013-10-01 11:06:09