作者:
strife00 (strifecloud)
2015-08-06 08:39:21大家好
小弟做了一個UITableViewController,裡面UITableViewCell資料是連接Parse取得
想用UIRefreshController來做往下拉的更新
加入UIRefreshControl後第一次往下拉更新有成功
但是第二次再往下拉的話,就會出現“fatal error: Array index out of range”
每次我加入新資料後,第一次往下拉更新都成功,但是只要再加入新資料,
第二次更新就一定會出現上面的問題,想請問各位大大要如何解決呢?
(之前還沒加入UIRefreshControl時,運作都很正常,
我寫了一個methods作為更新的按鈕之用,但因為這次想用下拉式更新)
希望能解決這個問題,感謝
我加入UIRefreshControll的程式碼如下:
viewDidLoad() {
super.viewDidLoad()
self.refreshControl = UIRefreshControl();
self.refreshControl?.attributedTitle = NSAttributedString(string: "Pull to refresh");
self.refreshControl?.addTarget(self, action: "refresh:", forControlEvents: UIControlEvents.ValueChanged)
}
func refresh(sender:AnyObject){
println("refresh")
self.loadData();
self.refreshControl?.endRefreshing();
}