#現状
Cellの生成の際に毎回AXRatingViewを呼び出し、
レーティングを表示しているためなのか、
上下にスクロールを繰り返しているとメモリ消費量が多くなり動作が重くなってしまいます。
#どうしたいのか
できるだけ上下させても動作を軽くしたいのですが、
どのように書き換えればよろしいでしょうか、ご教授願います。
#Source
Swift
1import UIKit 2import AXRatingView 3 4class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { 5 6 func tableView(table: UITableView, numberOfRowsInSection section: Int) -> Int { 7 return 10 8 } 9 10 func tableView(table: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 11 12 let cell = table.dequeueReusableCellWithIdentifier("TableCell", forIndexPath: indexPath) 13 14 let label1 = cell.viewWithTag(1) as! UILabel 15 label1.text = "あいうえお\nかきくけこ\nさしすせそ\nたちつてと" 16 star(cell) 17 18 return cell 19 } 20 21 func star(cell: UITableViewCell) { 22 23 let usersRating: AXRatingView = AXRatingView(frame: CGRectZero) 24 usersRating.translatesAutoresizingMaskIntoConstraints = false 25 usersRating.value = 1.0 26 usersRating.userInteractionEnabled = false 27 usersRating.sizeToFit() 28 cell.contentView.addSubview(usersRating) 29 30 } 31 32}

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。