Reputation: 123
This code is in my TableViewController and when I simulate it, the cells load with the right content, but the view can't be scrolled or clicked on. I put a prinln() in didSelectRowAtIndexPath and it didn't even log. When would this happen?
This my code in viewDidLoad
super.viewDidLoad()
var query = PFUser.query()
query.findObjectsInBackgroundWithBlock({
(objects: [AnyObject]! , error: NSError!) in
self.users.removeAll(keepCapacity: true)
for object in objects {
var user: PFUser = object as PFUser
var isfollowing:Bool = false
if user.username != PFUser.currentUser().username{
self.users.append(user.username)
var query = PFQuery(className: "followers")
query.whereKey("follower", equalTo: PFUser.currentUser().username)
query.whereKey("following", equalTo: user.username)
query.findObjectsInBackgroundWithBlock({ ( objects:[AnyObject]!, error: NSError!) -> Void in
if error == nil {
for object in objects {
isfollowing = true
}
self.following.append(isfollowing)
}
self.tableView.reloadData()
}
the code for filling in the table cells are very basic with returning a count of an array and textlabel being set as array[indexPath.row].
THANK YOU
Upvotes: 0
Views: 69
Reputation: 196
Why don't you just stick with the standart delegates from UITableView
..
Create a table in the storyboard and create a default cell with an identifier. Connect the ViewController
as the delegate of the table.
After you did that fill the array cells with the array you have.
example:
func numberOfSectionsInTableView(tableView: UITableView!) -> Int {
// Return the number of sections.
return 1
}
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
// Return the number of rows in the section.
return userArray.count
}
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
let cell = tableView.dequeueReusableCellWithIdentifier("objectCell", forIndexPath: indexPath) as UITableViewCell
var user:User = userArray.objectAtIndex(indexPath.row) as User
var imageView:UIImageView = cell.viewWithTag(1) as UIImageView
var ageLbl:UILabel = cell.viewWithTag(2) as UILabel
var nameLbl:UILabel = cell.viewWithTag(3) as UILabel
nameLbl.text = user.name
ageLbl.text = user.age
imageView.image = user.Image
return cell
}
Upvotes: 1