![](/img/trans.png)
[英]Swift / UITableViewCell: Add disclosure indicator, when entering editing mode
[英]Swift-Add disclosure indicator to a UITableViewCell
我是 iOS 新手。 我有 2 個表視圖控制器,我希望用戶單擊 1 個單元格以導航到其他控制器。
但是,在這里您可以看到項目旁邊的符號“>”,與 iOS 8 中的“設置”應用程序相同。https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/TableView_iPhone/TableViewAndDataModel/TableViewAndDataModel。 html
但是我無法將導航項添加到單元格中,無論我使用什么 segue,“>”都不會顯示。
任何的想法?
那個箭頭不是UINavigationItem
; 它是一個UITableViewCellAccessoryDisclosureIndicator
。
要將UITableViewCellAccessoryDisclosureIndicator
“箭頭”添加到單元格的附件視圖中,請添加以下行:
cell.accessoryType = UITableViewCellAccessoryType.DisclosureIndicator
然后在附件視圖被點擊時執行特定操作,實現tableView:accessoryButtonTappedForRowWithIndexPath:
。
更新:
UITableViewCellAccessoryType.DisclosureIndicator
就是現在
UITableViewCell.AccessoryType.disclosureIndicator
在 Swift 4 和 Swift 5 中,這將是:
cell.accessoryType = .disclosureIndicator
如果合適,您也可以在 IB 中設置它:屬性檢查器 > 表格視圖單元格 > 附件。
先說第一件事。 如果需要在視圖控制器之間進行導航,則需要將第一個視圖控制器嵌入到導航控制器中。 每個導航控制器維護一個堆棧,您可以在其中推送視圖控制器。 請參閱導航控制器文檔。 如果您希望默認顯示“>”,請轉到情節提要,單擊單元格,轉到右側的第四個選項卡,選擇附件作為“披露指示器”。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.