0
テーブルビューのセルを含むテーブルビューを作成しました。私はテーブルビューの異なる行のコンテンツを一覧表示することができます(私はテーブルビューの行にあるデバイスから曲をリストしています)。このコードを以下に示します。スクロール時にテーブルビューのコンテンツの順序が変更されるSwift
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath:NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! hostTableViewCell //hostTableViewCell is the custom cell class
cell.backgroundColor = UIColor.clearColor()
print("\(songList[indexPath.section + StaticThing.timesCalled].songTitle)")
cell.clientCellLabel!.text = songList[indexPath.section + StaticThing.timesCalled].songTitle
copyOfAllSongsArray.append(songList[indexPath.section + StaticThing.timesCalled].songTitle) // Taking text of the cells in an array
cell.detailTextLabel!.text = "\(songList[indexPath.section + StaticThing.timesCalled].artistName)"
StaticThing.doSomething()
if (StaticThing.timesCalled == songList.count){
StaticThing.timesCalled = 0
}
return cell;
}
最初に読み込んだときのテーブルビューにその内容が表示されます。ただし、毎回ページがスクロールされると、テーブルビューの内容が並べ替えられます。テーブルがスクロールされるたびに、コンテンツはランダムに並べ替えられます。この問題を解決する方法は?
どこにUITableViewデータソースを保存しましたか? – luiyezheng