您好, 任何一個可以指導我以下UIActionSheet與表視圖
- 我要添加與自定義圖像的ActionSheet。
- 在ActionSheet中,我想爲數據放置一個表視圖。
- 兩個按鍵(取消&完成)
感謝....
您好, 任何一個可以指導我以下UIActionSheet與表視圖
感謝....
檢查我的答案。我正在使用此代碼在動作表中顯示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)];
}
您是否嘗試過創建的tableview和兩個按鈕,設置它們的幀,然後在actionsheet做addSubview?您可能還需要繼承它並重寫它的drawRect方法。但我想你會有更多的運氣讓自己的觀點在你想要的時候進入或退出。我甚至不會開始考慮HIG對此的影響...... – 2011-03-22 06:14:12
你能告訴我如何顯示錶視圖作爲操作表意味着表視圖應該像操作表一樣出現? – Maulik 2011-03-22 08:13:40