Re: [問題] 想問有關UIRefreshControl
不好意思,經版友提醒,貼上我的loadData function如下:
@IBAction func loadData(){
timelineData.removeAll(keepCapacity: false);
var findTimelineData: PFQuery = PFQuery(className: "Sweets");
findTimelineData.findObjectsInBackgroundWithBlock{
(objects:[AnyObject]!, error: NSError!) -> Void in
if error == nil{
self.timelineData = objects.reverse() as! [PFObject]
self.tableView.reloadData();
}
}
}
並補充Xcode指出錯誤的行數如下:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
let cell: SweetTableViewCell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! SweetTableViewCell;
Xcode說這行錯了-> let sweet: PFObject = self.timelineData[indexPath.row] as PFObject;
cell.sweetTextView.text = sweet.objectForKey("content") as! String;
cell.titleTextView.text = sweet.objectForKey("title") as! String;
cell.location.setTitle((sweet.objectForKey("location")) as? String, forState: UIControlState.Normal);
可能是這邊有問題,但我不太知道是哪邊有問題,希望得到解決,感謝!!
※ 引述《strife00 (strifecloud)》之銘言:
: 大家好
: 小弟做了一個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();
: }
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 123.193.38.214
※ 文章網址: https://www.ptt.cc/bbs/MacDev/M.1438865756.A.9F4.html
※ 編輯: strife00 (123.193.38.214), 08/06/2015 21:23:26
→
08/06 21:55, , 1F
08/06 21:55, 1F
→
08/06 21:56, , 2F
08/06 21:56, 2F
→
08/06 21:57, , 3F
08/06 21:57, 3F
→
08/06 21:58, , 4F
08/06 21:58, 4F
→
08/06 21:58, , 5F
08/06 21:58, 5F
→
08/07 09:21, , 6F
08/07 09:21, 6F
→
08/08 14:14, , 7F
08/08 14:14, 7F
→
08/08 14:14, , 8F
08/08 14:14, 8F
→
08/08 14:14, , 9F
08/08 14:14, 9F
→
08/08 14:14, , 10F
08/08 14:14, 10F
→
08/08 14:14, , 11F
08/08 14:14, 11F
→
08/08 14:14, , 12F
08/08 14:14, 12F
→
08/08 14:15, , 13F
08/08 14:15, 13F
推
08/08 14:19, , 14F
08/08 14:19, 14F
→
08/08 14:19, , 15F
08/08 14:19, 15F
→
08/12 15:19, , 16F
08/12 15:19, 16F
→
08/12 15:20, , 17F
08/12 15:20, 17F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章