mercredi 24 juin 2015

UITableview Lag with custom UITableviewCells - iPhone 6 Plus

EDIT: POSSIBLE ANSWER: I am running this app on the simulator which may not be able to handle tableView's as easily as on an actual device so this may be the cause of the problem.

I am currently creating an app which displays elements from twitter in a UITableView with the use of custom UITableViewCell's, constrained with AutoLayout. There is an autosizing caption cell with a UIImageView underneath, When run on iPhone 5s and below, there is no lag and on iPhone 6 it is barely noticeable. However, on the 6 plus the table jumps when scrolled down and back up, which makes it unusable.

enter image description here

Here is the code for this particular cells cellForRowAtIndexPath:

       ...else if (feedSource[indexPath.section]["type"] as String! == "twitter" && indexPath.row == 0) {
        var twitterCell = tableView.dequeueReusableCellWithIdentifier("twitterCell") as! customTwitterCell

        twitterCell.selectionStyle = UITableViewCellSelectionStyle.None
        twitterCell.network.image = UIImage(named: "network_twitter")
        //Display Picture
        if let profileURLString = feedSource[indexPath.section]["profilePicture"] as NSString! {
            var profileURL = NSURL(string: profileURLString as String)
            twitterCell.displayPicture.setImageWithURL(profileURL, placeholderImage: UIImage(named: "loading"))
            twitterCell.displayPicture.layer.cornerRadius = 5
            twitterCell.displayPicture.clipsToBounds = true
        }

        //Username
        var username = feedSource[indexPath.section]["username"] as String!
        twitterCell.username.text = username

        //Caption
        var caption = feedSource[indexPath.section]["caption"] as String!
        twitterCell.caption.text = caption

        //Media
        var twitterMedia = feedSource[indexPath.section]["image_standard"] as String!
        var mediaURL = NSURL(string: twitterMedia)
        twitterCell.media.setImageWithURL(mediaURL, placeholderImage: UIImage(named: "loading"))
        twitterCell.media.contentMode = UIViewContentMode.ScaleAspectFit
        return twitterCell
    }

As I said, all the constraints are done in Auto layout because I find it is the easiest way to do it. Does anyone know how to fix it (or if I can provide any further information)

*EDIT: Added Code

Thanks

See more ..

Aucun commentaire:

Enregistrer un commentaire