Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法在tableview ios应用程序中向下滚动_Ios_Swift_Xcode - Fatal编程技术网

无法在tableview ios应用程序中向下滚动

无法在tableview ios应用程序中向下滚动,ios,swift,xcode,Ios,Swift,Xcode,我正在开发一个ios应用程序,它与instagram类似,但是它没有向下滚动页面并显示所有图像,这是为什么? 这是feed控制器,它也显示了一个错误,上面写着致命的:索引超出范围,我觉得这可能是连接的。我似乎无法向下滚动查看我上传的其他图片 import UIKit import Firebase import SDWebImage class FeedController: UIViewController , UITableViewDelegate, UITableViewD

我正在开发一个ios应用程序,它与instagram类似,但是它没有向下滚动页面并显示所有图像,这是为什么? 这是feed控制器,它也显示了一个错误,上面写着致命的:索引超出范围,我觉得这可能是连接的。我似乎无法向下滚动查看我上传的其他图片

  import UIKit
  import Firebase
  import SDWebImage


class FeedController: UIViewController , UITableViewDelegate, UITableViewDataSource {


@IBOutlet weak var tableV: UITableView!
var userEmailArray = [String] ()
var userCommentArray = [String] ()
var likeArray = [Int] ()
var userImageArray = [String] ()
override func viewDidLoad() {
    super.viewDidLoad()
    tableV.delegate = self
  //  tablev.datasource = self
    tableV.dataSource = self
 getDataFromFirestore()
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return userEmailArray.count

}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
       let cell = tableView.dequeueReusableCell(withIdentifier:"cellTable" , for: indexPath) as! Feed
       cell.user.text = userEmailArray[indexPath.row]
       cell.like.text = String(likeArray [indexPath.row])

       cell.comment.text = userCommentArray[indexPath.row]
       cell.imageee.sd_setImage(with: URL(string: self.userImageArray[indexPath.row]))
       return cell
   }
func getDataFromFirestore(){

    let fireStoreDatabase = Firestore.firestore()
  //  let settings = fireStoreDatabase.settings
    //settings.areTimestampsInSnapshotsEnabled = true
  //  fireStoreDatabase.settings = settings
    fireStoreDatabase.collection("post").addSnapshotListener { (snapshot, error) in
        if error != nil {
            print(error?.localizedDescription)
        }else{
            if  snapshot?.isEmpty != true && snapshot != nil {
                for document in snapshot!.documents {
                   let documentID =  document.documentID


                    if let postedBy = document.get("postedby") as? String {
                        self.userEmailArray.append(postedBy)
                    }
                    if let postComment = document.get("postComment") as? String{
                        self.userCommentArray.append(postComment)
                    }
                    if let likes = document.get("likes") as? Int{
                        self.likeArray.append(likes)
                    }
                    if let imageUrl = document.get("imageurl") as? String {
                        self.userImageArray.append(imageUrl)
                    }
                    self.tableV.reloadData()
                }
               // snapshot!.documents



            }
        }
    }
}


}

检查是否启用了滚动,以及userEmailArray的计数是多少?请尝试打印userEmailArray.count,该计数可能为零。我在
tableView(\u:cellForRowAt:)中使用多个数组不断获取索引超出范围错误。
是个坏主意。创建一个结构来保存数据并使用这些结构的单个数组。检查是否启用了滚动,以及
userEmailArray
count是多少?尝试打印userEmailArray.count,这可能是零。我一直在使用
tableView(u:cellForRowAt:)
中的多个数组来获取索引超出范围错误,这是个坏主意。创建一个结构来保存数据,并使用这些结构的单个数组。