我有一個拆分視圖控制器,其中左側持有表視圖控制器。當我點擊表格單元格的詳細信息按鈕時,如何在彈出窗口中顯示一個操作表單?如何在彈出窗口中顯示動作表?
7
A
回答
15
嘗試這種情況:
UIActionSheet *popupSheet = [[UIActionSheet alloc] initWithTitle:@"Title"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:@"No Way !"
otherButtonTitles:nil];
popupSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
UIButton * disclosureButton = (UIButton *)cell.accessoryView;
[popupSheet showFromRect:disclosureButton.bounds inView:cell.accessoryView animated:YES];
[popupSheet release];
的UIActionSheet docs狀態下showFromRect:inView:animated:
方法:動作片在酥料餅,其箭頭指向視圖的指定矩形
顯示器(在我們的例子中詳細披露按鈕)。彈出窗口不與指定的矩形重疊。
0
我用這個更高級的使用:
- 發現定製accesoryView(cell.accesoryView)
- 如果是空的,發現產生accesoryView(UIButton的),如果電池有
- 如果UIButton不存在,找到單元格環境視圖(UITableViewCellContentView)
- 如果單元環境視圖不存在,請使用單元格視圖
可用於UIActionSheet或UIPopoverController。
這裏是我的代碼:
UIView *accessoryView = cell.accessoryView; // finds custom accesoryView (cell.accesoryView)
if (accessoryView == nil) {
UIView *cellContentView = nil;
for (UIView *accView in [cell subviews]) {
if ([accView isKindOfClass:[UIButton class]]) {
accessoryView = accView; // find generated accesoryView (UIButton)
break;
} else if ([accView isKindOfClass:NSClassFromString(@"UITableViewCellContentView")]) {
// find generated UITableViewCellContentView
cellContentView = accView;
}
}
// if the UIButton doesn't exists, find cell contet view (UITableViewCellContentView)
if (accessoryView == nil) {
accessoryView = cellContentView;
}
// if the cell contet view doesn't exists, use cell view
if (accessoryView == nil) {
accessoryView = cell;
}
}
[actionSheet showFromRect:**accessoryView.bounds** inView:**accessoryView** animated:YES];
中的iOS 4.3測試5.1
最好的自定義的方法來使用:
-(UIView*)getViewForSheetAndPopUp:(UITableViewCell*)cell;
和方法代碼:
-(UIView*)getViewForSheetAndPopUp:(UITableViewCell*)cell {
UIView *accessoryView = cell.accessoryView;
if (accessoryView == nil) {
UIView *cellContentView = nil;
for (UIView *accView in [cell subviews]) {
if ([accView isKindOfClass:[UIButton class]]) {
accessoryView = accView;
break;
} else if ([accView isKindOfClass:NSClassFromString(@"UITableViewCellContentView")]) {
cellContentView = accView;
}
}
if (accessoryView == nil) {
accessoryView = cellContentView;
}
if (accessoryView == nil) {
accessoryView = cell;
}
}
return accessoryView;
}
相關問題
- 1. 在彈出窗口中顯示錶格
- 2. 如何顯示其他彈出窗口上的彈出窗口?
- 3. 如何在我的主窗口中顯示彈出窗口?
- 4. 如何在所有活動中顯示一個彈出窗口?
- 5. 如何在彈出窗口中顯示移動預覽
- 6. 如何在我的活動中顯示一個彈出窗口?
- 7. 如何顯示彈出窗口
- 8. 如何顯示彈出窗口?
- 9. 如何顯示彈出窗口?
- 10. 如何在模態彈出窗口中顯示錶格
- 11. 如何在HTML5彈出窗口中顯示Google圖表
- 12. 彈出窗口不顯示
- 13. 彈出窗口不顯示
- 14. 彈出窗口不顯示
- 15. 顯示彈出窗口
- 16. iPhone:MKAnnotation顯示彈出窗口?
- 17. 如何僅在窗口範圍內顯示彈出窗口?
- 18. 如何在父窗口頂部顯示彈出窗口?
- 19. 作爲彈出窗口顯示UserControl
- 20. 在webgrid中顯示彈出窗口
- 21. 在iOS中顯示彈出窗口
- 22. 在c#中顯示彈出窗口.net
- 23. 在彈出窗口中顯示結果
- 24. 在彈出窗口中顯示RecyclerView
- 25. 在彈出窗口中顯示值
- 26. 在彈出窗口中顯示html
- 27. 在彈出窗口中顯示progressBar
- 28. 在wordpress中顯示彈出窗口
- 29. 在彈出窗口中顯示UISplitViewController
- 30. 在Python中顯示彈出窗口(PyQt4)