2016-05-01 8 views
-3

こんにちはみんなイム練習迅速にnewestから注文し、テーブルビューの迅速リストポスト、 と私は最新のポストを作りたいが、ユーザーが見ることができるようにするテーブルビュー の上部に表示されます最新の投稿を最初に!makestagram - Makeschoolのmakestagramプロジェクトによって古い

誰でもお手伝いできますか? は、ここに私のコード

override func viewDidLoad() { 
    super.viewDidLoad() 

    timelineComponent = TimelineComponent(target: self) 
    self.tabBarController?.delegate = self 



     } 

    func takePhoto(){ 
    // instantiate photo taking class, provide callback for when photo is selected 
    photoTakingHelper = PhotoTakingHelper(viewController: self.tabBarController!,callback:{ (image: UIImage?)in 
     let post = Post() 
     post.image.value = image! 

     post.uploadPost() 
     } 

    ) 

} 
override func viewDidAppear(animated: Bool) { 
timelineComponent.loadInitialIfRequired() 
      } 

func loadInRange(range: Range<Int>, completionBlock: ([Post]?) -> Void) { 

ParseHelper.timelineRequestForCurrentUser(range) { 
    (result: [PFObject]?, error: NSError?) -> Void in 
    if let error = error { 
    ErrorHandling.defaultErrorHandler(error) 
    } 


    let posts = result as? [Post] ?? [] 


    completionBlock(posts) 
} 

}

}

extension TimelineViewController: UITableViewDataSource { 
func numberOfSectionsInTableView(tableView: UITableView) -> Int { 
    return self.timelineComponent.content.count 
} 
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 
    return 1 
} 
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 
    let cell = tableView.dequeueReusableCellWithIdentifier("PostCell")as! PostTableViewCell 
    let post = timelineComponent.content[indexPath.section] 
    post.downloadImage() 
    post.fetchLikes() 
    cell.post = post 



    return cell 

} 

}

extension TimelineViewController: UITableViewDelegate{ 
func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) { 
    timelineComponent.targetWillDisplayEntry(indexPath.section) 

} 
     func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { 
    let headerCell = tableView.dequeueReusableCellWithIdentifier("PostHeader")as! PostSectionHeaderView 
    let post = self.timelineComponent.content[section] 
    headerCell.post = post 
    return headerCell 
} 
func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { 
    return 40 
} 

}

+0

何の上に? – Shubhank

+3

これは[動作しません](http://importblogkit.com/2015/07/does-not-work/)の投稿です。あなたはあなたの問題を十分に説明していないので、問題を説明するために[質問を編集しない](http://stackoverflow.com/posts/36970324/edit)をしていないと、質問が保留になる可能性があります。私は[MCVE](http://stackoverflow.com/help/mcve)での作業をお勧めします。 – nhgrif

+0

すべての投稿の一番上に、最新のものから古いものへのリスト! –

答えて

0

私は最終的にそれを把握です!

パースのPFqueryはupdatedAt方法

私はupdatedAtにcreatedAtを変更しました。

これは完全に機能します。

+0

よくできました。副題として、あなたの投稿に何か問題があるのを見ていますか?パースを使用していると言わず、データのパースバックエンドをクエリしていたコードを含めていませんでした。将来的には、ヘルプをデバッグするために、潜在的に問題のある領域を考え、問題について明確に他の人に説明するようにしてください。 – NSNoob

+0

あなたの親切な助言のおかげで、私はそれから多くを学ぶ!次回はもっとうまくやるよ。 –