我花了幾個小時試圖找到一個解決方案,但我總是沒有結果。TableView內的分段控件
我正在嘗試在TableView
內部爲段控制的兩個視圖創建一個段落控件。
https://www.youtube.com/watch?v=dw7kytoA3KU&t=198s是我嘗試完成的一個完美例子,但是用戶放入了1個CustomCell並且代碼有點混亂。
我的第一個CustomCell包含圖像,名稱和數字。 我的第二個CustomCell只包含一個圖像。
所以我的問題是...
我應該如何創建兩個陣列兩個CustomCell?的就是我試圖完成
例
自定單元1:
let names = ["Pizza","Soup","Tacos","Chicken", "Beef"]
let image = [UIImage(named: "Pizza1"), UIImage(named: "Soup1"), UIImage(named: "Tacos1"), UIImage(named: "Chicken1"), UIImage(named: "Beef1")]
let numbers = ["1", "2", "3", "4", "5"]
自定單元2:
let photo = [UIImage(named: "Pic1"), UIImage(named: "Pic2"), UIImage(named: "Pic3")]
從我研究過的,當它'有時候需要將CustomCell文件和兩個CustomCell放入我的代碼中,這是否正確?
let nib = UINib(nibName: "CustomCell", bundle: nil) tableView.register(nib, forCallReuseIdentifier: "CustomCell1") tableView.register(nib, forCallReuseIdentifier: "CustomCell2")
應該爲此返回什麼?
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
這部分是我得到什麼進入
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
總結困惑:我試圖創建一個的tableView段控制有2 CustomCells。我希望該段的第一個視圖是CustomCell,它具有圖像,名稱和編號。該部分的第二個視圖只有圖像。
謝謝!
TableView ...裏面...段控制? – Matthew
@Matthew ...我的不好,一個UISegmented控件在桌面視圖中 – William