2017-06-24 3 views
0

私はUITableViewにデータをロードしています。最初の負荷を適切UITableView indexPath.rowが増加しない

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {} 

indexPath.row増分で最初の10個のセルに対して適切に発生し、データソースからの適切なセルにデータをロードします。私はテーブルの一番下に達すると、さらに負荷を実装しました。今、FUNCのtableViewと呼ばれますが、

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 

にindexPath.row = 9.私はチェッカーを実装しているで立ち往生しているそして行の適切な数が追加されたことが表示されます。

編集:2番目のuitableviewに問題があります(このシーンに2つあります)。チェッカーは、呼び出されたprintステートメントで、適切なuitableViewを返します。これは、tableViewが同じ値になる前に発生します。

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 

     if tableView == self.table { 
      return users2.count 

     } 
     else { 
      print("married barry", tableFeedCount) 
      return tableFeedCount 
     } 
    } 
+0

働いていましたか? – tek3

答えて

0

次のことを試してみてください。

宣言ブール

let boolNotMoreData : Bool = true 

は、データソース

let arrResponse: [Any]? = (responseObject["news"] as? [Any]) 
if arrResponse?.count == 0{ 
       boolNotMoreData = false; 
     } 
    for dictResponse in arrResponse as! [[String: Any]] { 
      self.arrDataSource.append(NewsClass(responseDict: dictResponse)) 
     } 
     self.tblViewNews?.reloadData() 

に新しいデータを追加新しいを取得データ

private func tableView(_ tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAt indexPath: IndexPath) { 
     if indexPath.row == arrNews.count - 1 { 
      if boolNotMoreData { 
       currentPage += 1 
       getYourData() 
      } 
     } 
    } 
0

これはどのようにあなたの 'チェッカー' のコードがどのように見えるん成功しました

@IBOutlet weak var Submitted: UITableView! 
    @IBOutlet weak var ViewAssigenment: UITableView! 
    var Arrayone:[String] = [] 
    var ArrayTwo:[String] = [] 

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int 
     { 
      var count:Int? 
      if tableView == self.ViewAssigenment 
      { 
       count = Arrayone.count 
      } 
      else if tableView == self.Submitted 
      { 
       count = ArrayTwo.count 
      } 
      return count! 
     } 

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell 
    { 

     if tableView == self.ViewAssigenment 
     { 
      let cell = tableView.dequeueReusableCell(withIdentifier: "ViewCell") as! 
      ViewAssigenmentTableViewCell 
      let obj =Arrayone[indexPath.row] 

      cell.lblTitle.text = obj.AssTitle 



      return cell 

     } 
     else 
     { 
      let cell1 = tableView.dequeueReusableCell(withIdentifier: "Submittcell") as! SubmittedAssigenmentTableViewCell 
      let obj2 = ArrayTwo[indexPath.row] 

      cell1.lbltitle.text = obj2.AssTitle 

      return cell1 
     } 

    } 
関連する問題