2016-09-29 4 views
1

非常にシンプルなデモアプリケーションをビルドして、tableViewをインストールした状態でUIViewControllerを使用する際に見つかった2つのバグを説明しました。これらの問題は、標準のUITableviewControllerを使用している場合は表示されません。複数のUITableViewBugs with refreshControl

Video to demonstrate the bug

project link to github

  1. 私はゆっくりとリフレッシュするために引いたときに、基本的に、私は下向きに、このジャンプ(約30点)を取得します。また、リフレッシャーがアクティブになる前に、フェアビットをドラッグする必要があります(画面の半分程度)。私が速く引っ張っても問題はない。

  2. hideNavigationBarOnSwipeとrefreshControlを同時に実装すると、セクションヘッダーがすべて醜くて場所がずれているため(ビデオの後半に表示されるため)、私はAppleが、私はそれをやってみる必要があり、次の3つの選択肢のどれ、それを改善かどうかを確認するためにショットを取りたい場合は

私は、バグのこの種のために、と思いまして。 (このプロジェクトはxcode7.3上に構築され、迅速2、IOS9.0

  1. 迅速2から更新Xcodeの迅速3.
  2. から7から8
  3. へのアップデートが高いIOSバージョンのアプリをビルドします

----完全なコード----

import UIKit 

class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { 

    @IBOutlet weak var myTableView: UITableView! 

    var refreshControl: UIRefreshControl! 

    override func viewDidLoad() { 
     super.viewDidLoad() 
     myTableView.delegate = self 
     myTableView.dataSource = self 

     navigationController!.hidesBarsOnSwipe = true 

     refreshControl = UIRefreshControl() 
     refreshControl.addTarget(self, action: #selector(ViewController.refresh), forControlEvents: .ValueChanged) 
     myTableView.addSubview(refreshControl) 
    } 

    func refresh() { 

    } 

    @IBAction func stopRefreshingBtnPressed(sender: AnyObject) { 
     refreshControl.endRefreshing() 
    } 

    func numberOfSectionsInTableView(tableView: UITableView) -> Int { 
     return 10 
    } 

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 
     return 10 
    } 

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 
     let cell = tableView.dequeueReusableCellWithIdentifier("myCell", forIndexPath: indexPath) 
     cell.textLabel?.text = "section \(indexPath.section) row \(indexPath.row)" 
     return cell 
    } 

    func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { 
     return 20 
    } 

    func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? { 
     return "Section Header \(section)" 
    } 
} 

答えて

2
override func viewDidLoad() { 
    super.viewDidLoad() 
    myTableView.delegate = self 
    myTableView.dataSource = self 
    navigationController!.hidesBarsOnSwipe = true 

    refreshControl = UIRefreshControl() 

    //Create an instance of a UITableViewController. This will host your UITableView. 
    let tableController = UITableViewController() 

    //Add tableController as a childViewController and set its tableView property to your UITableView. 
    self.addChildViewController(tableController) 
    tableController.tableView = myTableView 
    tableController.refreshControl = self.refreshControl 
} 
+0

グレートソリューション。ポインティングに感謝「UIRefreshControlはサブビューではなく、テーブルのリフレッシュ制御を意図したものです。 それはちょうどサブビューではなく、セルのように再計算を強制するセルと見なされます。 – user125972

関連する問題