HOW TO SET ACTIVITY INDICATOR IN UITABLEVIEW IN OBJECTIVE-C?

JAMES Williams

Total Post:7

Points:49
Posted by  JAMES Williams
 687  View(s)
Ratings:
Rate this:
I want to display activity indicator for the initial load time for each collection view cell. So I tried to place it in the table view delegate method cellForItemAtIndexPath: and created 25 pixels above the cell for some reason.
Below is my code:
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
    let cell = self.collectionView.dequeueReusableCellWithReuseIdentifier("AACollectionViewCell", forIndexPath: indexPath) as! AACollectionViewCell
    let activityView = UIActivityIndicatorView (activityIndicatorStyle: .Blue)
    activityView.center = cell.myImage.center

    activityView.center = cell.contentView.center
    activityView.startAnimating()

    return cell
}
Now, Please tell me the proper way to handle the activity indicator or what the wrong in my code..!
Thank you.
  1. Tarun Kumar

    Post:214

    Points:1642
    Re: How to set Activity Indicator in UITableView in Objective-C?

    You can use cell.contentView.center which gives us the frame of contentView from its superView' coordinate system.
    User like the below example:
    activityView.center = CGPointMake(cell.contentView.frame.size.width / 2,
                                           cell.contentView.frame.size.height / 2)
    I hope it will be helpful for you.

      Modified On Apr-25-2016 01:41:23 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!