我需要獲取在所選行的Headerview中設置的字符串。我需要這些信息來決定該行將被髮送到哪個視圖。我已經有了Row名字。但是我需要在Headerview中使用的字符串的名稱。Swift:如何從headerViewer獲取UItextlabel
0
A
回答
1
按照步驟
的部分的標題名稱等採取陣列和聲明以上viewDidLoad中方法
let sectionHeaderArray = ["Header1", "Header2"]
實現用於視圖的方法的節頭
func tableView(tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) { let header = view as! UITableViewHeaderFooterView header.textLabel?.text = self.sectionHeaderArray[section] }
in didDeselectRowAtIndexPath方法你可以得到回在節名
func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) { let section_name = self.sectionHeaderArray[indexPath.section] }
希望這會幫助你。
+0
嗨Ujesh,謝謝你的答案!我相信我不清楚自己想要什麼,下次我會在問題中加入一些代碼。我認爲你的解決方案可能會有效。但我以另一種方式做到了。骯髒的方式;)我在行中做了一個極端的UILabel,使該標籤不可見。然後分配給標籤上我在標題中使用的值。這樣我可以讀取didSelectRowAt中的值,並在下一個視圖中使用。 –
相關問題
- 1. 調用從UITextLabel
- 2. Swift如何從UITableViewRowAction獲取訪問func
- 3. 如何從UIDatePicker獲取數據 - Swift
- 4. 如何使用Swift從NSURLSession獲取cookie?
- 5. 如何從Swift獲取HTML源代碼
- 6. 如何在swift中從addressBook獲取imageContact?
- 7. 如何從swift中獲取數據?
- 8. 如何在Swift中從NSDictionary獲取NSDictionary?
- 9. Swift:從NSTextField獲取一行
- 10. Swift - 從CMSampleBuffer獲取kCMSampleBufferAttachmentKey_DroppedFrameReason
- 11. Swift - 從現場獲取CCNode
- 12. 獲取CIImage從UIImage的(SWIFT)
- 13. Swift - 從MetaType獲取類名?
- 14. 如何從另一個對象設置UItextlabel文本
- 15. NSPersistentDocument,Swift,macOS和storyboards - 如何獲取managedObjectContext?
- 16. Swift:如何獲取UIImagePickerControllerMediaType的文檔值
- 17. 如何在CoreBluetooth Swift中獲取kCBAdvDataManufacturerData?
- 18. 如何在swift中獲取NsKeyValueObservationinfo?
- 19. 如何在Swift中獲取UIStoryboard數組?
- 20. Swift:如何從解析中獲取今天製作的對象?
- 21. Swift:如何從NSString數組中獲取最後一個整數?
- 22. 如何從2個組件的UIPickerView中獲取值? swift
- 23. 如何從日曆中獲取所有事件(Swift)
- 24. 如何從Swift 3獲取MS翻譯器訪問令牌?
- 25. Swift 3:如何從國家代碼獲取語言代碼?
- 26. 如何從swift中獲取錯誤密鑰值
- 27. 如何使用swift從CDTReplicator對象獲取複製ID?
- 28. 如何從swift 3獲取Google聯繫人列表?
- 29. 如何在Swift中從UIImagePickerController獲取編輯後的圖像?
- 30. 如何從Firebase獲取Swift中的下一個數據
您想在行上點擊時獲取節標題文本嗎?對 ? – Ujesh
請把代碼質疑你的嘗試。 – Ujesh