I have a UICollectionView inside a popupview which is just a simple view in a xib file. In the same xibfile I have my UICollectionViewCell like this:
The View is connected to SampleViewController class and the UICollectionViewCell is connected to PekProfil class
The code I use for displaying the cells is
[_collectionView registerClass:[PekProfil class] forCellWithReuseIdentifier:#"vinnare"];
_collectionView.delegate = self;
_collectionView.dataSource = self;
and:
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"vinnare";
PekProfil * cellen = (PekProfil *)[collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
cellen.backgroundColor = [UIColor grayColor];
if (cellen==nil) {
cellen = [[PekProfil alloc] init];
}
NSString * iden = [_winners objectAtIndex:indexPath.row];
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:iden
parameters:nil
HTTPMethod:#"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
// Handle the result
NSLog(#"fetched friends:%#", result);
cellen.pekProfilNamn.text = [result objectForKey:#"name"];
NSString * ideno = [NSString stringWithFormat:#"https://graph.facebook.com/%#/picture?width=640&height=640", iden];
NSLog(#"IDEN:%#", ideno);
NSString *pictureUrl = ideno;
NSURL * url = [NSURL URLWithString:pictureUrl];
NSLog(#"PICURL:%#", pictureUrl);
NSData *data = [NSData dataWithContentsOfURL:url];
NSLog(#"%#", data);
UIImage *img = [[UIImage alloc] initWithData:data];
//roundpic
CALayer *imageLayer = cellen.profilePicView.layer;
[imageLayer setCornerRadius:5];
[imageLayer setBorderWidth:1];
[imageLayer setMasksToBounds:YES];
[cellen.profilePicView.layer setCornerRadius:cellen.profilePicView.frame.size.width/2];
[cellen.profilePicView.layer setMasksToBounds:YES];
//END
cellen.profilePicView.image = img;
}];
return cellen;
}
And I know that the facebookcode works since I use the same code in other places.
However running this only displays this:
Any ideas why the content is not displaying?
You should create a custom subclass of UiCollectionViewCell. If you want to layout your cell in IB check include XIB file. It's not possible to combine classes like this in objective C. Register you nib your reuse identifier and make your image view and label public properties that you can then set in cellForItemAtIndexPath
Related
I need to show flickr public images in a UICollectionView. I have done all the things, but images don't load in the UICollectionView. I am new to objective-c. Please help.
authorIds = [[NSMutableArray alloc] init];
dateTaken = [[NSMutableArray alloc] init];
smallImageUrlArray = [[NSMutableArray alloc] init];
largeImageUrlArray = [[NSMutableArray alloc] init];
smallImageArray = [[NSMutableArray alloc] init];
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.minimumLineSpacing = 10;
layout.minimumInteritemSpacing = 10;
layout.sectionInset = UIEdgeInsetsMake(110, 20, 20, 20);
_collectionView = [[UICollectionView alloc] initWithFrame:self.view.frame collectionViewLayout:layout];
[_collectionView setDataSource:self];
[_collectionView setDelegate:self];
[_collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:#"cellIdentifier"];
[_collectionView setBackgroundColor:[UIColor blackColor]];
[self.view addSubview:_collectionView];
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return totalImageNo;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:#"cellIdentifier" forIndexPath:indexPath];
UIImageView *cellImageView = (UIImageView *)[cell viewWithTag:100];
cellImageView.image = [UIImage imageNamed:[smallImageUrlArray objectAtIndex:indexPath.row]];
//[self.view addSubview:cellImageView];
[cell.backgroundView addSubview:cellImageView];
// NSLog(#"%#",[smallImageUrlArray objectAtIndex:indexPath.row]); //Here can show Img's values correctly
cell.backgroundColor=[UIColor darkGrayColor];
return cell;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
return CGSizeMake(160, 160);
}
In below I am fetching Flickr images and storing in array. then want to load the smallImageArray in the UICollection view. but nothing shows up.
-(void)fetchFlickrPublicImages
{
NSString *urlString = [NSString stringWithFormat:#"http://api.flickr.com/services/feeds/photos_public.gne?format=json&tags=data"];
NSURL *url = [NSURL URLWithString:urlString];
NSData *badJSON = [NSData dataWithContentsOfURL:url];
NSString *dataAsString = [NSString stringWithUTF8String:[badJSON bytes]];
NSString *correctedJSONString = [NSString stringWithString:[dataAsString substringWithRange:NSMakeRange (15, dataAsString.length-15-1)]];
correctedJSONString = [correctedJSONString stringByReplacingOccurrencesOfString:#"\\'" withString:#"'"];
NSData *correctedData = [correctedJSONString dataUsingEncoding:NSUTF8StringEncoding];
NSError* error;
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:correctedData options:kNilOptions error:&error];
NSArray *images = [json objectForKey:#"items"];
for (NSDictionary *image in images)
{
NSString *authorId = [image objectForKey:#"author_id"];
[authorIds addObject:(authorId.length > 0 ? authorId: #"Untitled")];
NSString *largeImageUrl = [NSString stringWithFormat:#"%#",[[image objectForKey:#"media"] objectForKey:#"m"]];
NSString *smallImageUrl = [largeImageUrl stringByReplacingOccurrencesOfString:#"_m" withString:#"_s"];
[smallImageUrlArray addObject:smallImageUrl];
[dateTaken addObject:[NSString stringWithFormat:#"%#",[image objectForKey:#"date_taken"]]];
[largeImageUrlArray addObject:[NSString stringWithFormat:#"%#",[[image objectForKey:#"media"] objectForKey:#"m"]]];
totalImageNo = authorIds.count;
}
for (int i=0; i< smallImageUrlArray.count; i++) {
UIImage * image = [UIImage imageWithData:[NSData dataWithContentsOfURL:
[NSURL URLWithString:[smallImageUrlArray objectAtIndex:i]]]];
[smallImageArray addObject:image];
}
NSLog(#"%#", smallImageArray);
NSLog(#"%ld", (long)totalImageNo);
// NSLog(#"authorIds: %#\n\n", authorIds);
// NSLog(#"photoURLsLareImage: %#\n\n", smallImageUrlArray);
// NSLog(#"photoURLsLareImage: %#\n\n", largeImageUrlArray);
}
You should add your UIImageView to the collection view cell's contentView, NOT backgroundView.
In your code ,
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UIImageView *cellImageView = (UIImageView *)[cell viewWithTag:100];
cellImageView.image = [UIImage imageNamed:[smallImageUrlArray objectAtIndex:indexPath.row]];
[cell.backgroundView addSubview:cellImageView];
}
you are assigning image as url . but in your method named fetchFlickrPublicImages where you are downloading images directly.
better you write code like
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UIImageView *cellImageView = (UIImageView *)[cell viewWithTag:100];
cellImageView.image =(UIImage*)[smallImageArray objectAtIndex:indexPath.row];
[cell.contentView addSubView cellImageView];
}
i am new to ios, i read this great tutorial to load local images from an array:
http://www.techotopia.com/index.php/An_iOS_7_Storyboard-based_Collection_View_Tutorial
Its all working smooth, but that is only with static data, i need to load images from a list of url.
I changed this array: (inside: MyCollectionViewController.m / -viewDidLoad)
_carImages = [#[#"IMG_2473.jpg",
#"IMG_2507.jpg",
#"IMG_2527.jpg",
#"IMG_2529.jpg",
#"IMG_2532.jpg",
#"IMG_2533.jpg",
#"IMG_2551.jpg",
#"IMG_2552.jpg",
#"IMG_2694.jpg"
] mutableCopy];
to this one:
_carImages = [#[#"http://img.webmd.com/dtmcms/live/webmd/consumer_assets/site_images/articles/health_tools/baby_skin_care_slideshow/getty_rm_photo_of_babies_shopping.jpg",
#"http://www.northernillinoiscouponing.com/wp-content/uploads/2013/01/Colorful_Shopping_bags.jpg",
#"https://origin.ih.constantcontact.com/fs057/1105082123206/img/34.jpg",
#"http://swipetelecom.com/blog/wp-content/uploads/shopping.jpg",
#"http://1000thriftythings.com/wp-content/uploads/2012/11/goodwill-pet-section.jpg",
#"http://msophiapr.com/wp-content/uploads/2009/10/new-illustration-flat-girls-only1.jpg",
#"http://swipetelecom.com/blog/wp-content/uploads/shopping.jpg",
#"http://www.gobol.in/blog/wp-content/uploads/2013/12/online-shopping.jpg",
#"http://www.birth.com.au/Birth/files/9c/9c4ed300-0dc0-4c62-a638-d1afb102fcae.jpg",
#"http://www.islandnutznews.com/upload_pic/resize_1338925187.jpg"
] mutableCopy];
And this is the code for MyCell: (inside: MyCollectionViewController.m / -collectionView:cellForItemAtIndexPath:)
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
MyCollectionViewCell *myCell = [collectionView
dequeueReusableCellWithReuseIdentifier:#"MyCell"
forIndexPath:indexPath];
UIImage *image;
long row = [indexPath row];
image = [UIImage imageNamed:_carImages[row]];
myCell.imageView.image = image;
//myCell.imageView.contentMode = UIViewContentModeScaleAspectFit;
//change width of frame
CGRect frame = myCell.imageView.frame;
frame.size.width = 160;
myCell.imageView.frame = frame;
return myCell;
}
But its not working out, probably i am missing something here.
Ideally, after getting this sorted out, i will use JSON for populating _carImages array.
Please advice, thank you!
------------------------------
UPDATE
As per the answer by #AntonStremovskiy below, here's my updated code (incase if someone wanted):
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"MyCell";
MyCollectionViewCell *collectionCell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
if (!collectionCell) {
collectionCell = [[MyCollectionViewCell alloc] init];
}
collectionCell.imageView.image = nil;
NSString *url = [_carImages objectAtIndex:indexPath.item];
[NSURLConnection sendAsynchronousRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
collectionCell.imageView.image = [UIImage imageWithData:data];
}];
return collectionCell;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"imageCell";
ImageCollectionViewCell* collectionCell = [self.imageCollectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
if (!collectionCell) {
collectionCell = [[ImageCollectionViewCell alloc] init];
}
collectionCell.imageFromInstagram.image = nil;
NSString *url = [imagesArray objectAtIndex:indexPath.item];
[NSURLConnection sendAsynchronousRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
collectionCell.imageFromInstagram.image = [UIImage imageWithData:data];
}];
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
view.backgroundColor = [UIColor colorWithRed:0.062 green:0.369 blue:0.689 alpha:0.8f];
collectionCell.selectedBackgroundView = view;
return collectionCell;
}
Something like that
Very new to AFNetworking, but after many SO questions... I've concluded that this is the solution to my issue.
I've got a hierarchy of JSON data loading my TableViewController cells dynamically. All of my text strings are loading appropriately but the image from my URL is not making it to my imageview.
Before utilizing the AFNetworking library, I had the images loaded, but I was experiencing some issues with the photos not staying loaded when I scrolled away and returned (they had to load again.)
What am I missing to get my images in there?
TableViewController.m
-(void)viewDidLoad {
[super viewDidLoad];
// Set the side bar button action. When it's tapped, it'll show up the sidebar.
siderbarButton.target = self.revealViewController;
siderbarButton.action = #selector(revealToggle:);
// Set the gesture
[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
self.tableView.backgroundColor = [UIColor whiteColor];
self.parentViewController.view.backgroundColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1];
self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"logo_app_white.png"]];
NSURL *myURL = [[NSURL alloc]initWithString:#"http://domain.com/json2.php"];
NSData *myData = [[NSData alloc]initWithContentsOfURL:myURL];
NSError *error;
jsonArray = [NSJSONSerialization JSONObjectWithData:myData options:NSJSONReadingMutableContainers error:&error];
[tableView reloadData]; // if tableView is unidentified make the tableView IBOutlet
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return jsonArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NeedCardTableViewCell *cell = (NeedCardTableViewCell *) [tableView dequeueReusableCellWithIdentifier:#"needCard"];
if (cell == nil)
{
cell = [[NeedCardTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:#"needCard"];
}
NSDictionary *needs = jsonArray[indexPath.row]; // get the data dict for the row
cell.textNeedTitle.text = [needs objectForKey: #"needTitle"];
cell.textNeedPoster.text = [needs objectForKey: #"needPoster"];
cell.textNeedDescrip.text = [needs objectForKey: #"needDescrip"];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager GET:#"userImage" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(#"JSON: %#", responseObject);
_imageProfPic.image = responseObject;
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(#"Error: %#", error);
}];
return cell;
}
Have you tried using the AFNetworking+UIImageView category? You can then call:
[_imageProfPic setImage:[NSURL URLWithString:#"http://myimageurl.com/imagename.jpg"]];
This will make a request and then set the returned image to your UIImageView's UIImage without you having to do anything else. You should also consider initializing NSURLCache in your AppDelegate:
NSURLCache *cache = [[NSURLCache alloc] initWithMemoryCapacity:4 * 1024 * 1024
diskCapacity:10 * 1024 * 1024
diskPath:nil];
[NSURLCache setSharedURLCache:cache];
Take a look at NSHipster's run down on NSURLCache. This will help reload images, and all your requests, much faster the second time around. This is increasingly important when dealing with images and tables.
Manage to figure this one out with the use of this tutorial:
Networking Made Easy with AFNetworking
I used the final snippet of code to get my desired result:
NSURL *url = [[NSURL alloc] initWithString:[movie objectForKey:#"artworkUrl100"]];
[cell.imageView setImageWithURL:url placeholderImage:[UIImage imageNamed:#"placeholder"]];
I cut the second line of his code because I already have an if statement in my PHP/JSON
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NeedCardTableViewCell *cell = (NeedCardTableViewCell *) [tableView dequeueReusableCellWithIdentifier:#"needCard"];
if (cell == nil)
{
cell = [[NeedCardTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:#"needCard"];
}
NSDictionary *needs = jsonArray[indexPath.row]; // get the data dict for the row
cell.textNeedTitle.text = [needs objectForKey: #"needTitle"];
cell.textNeedPoster.text = [needs objectForKey: #"needPoster"];
cell.textNeedDescrip.text = [needs objectForKey: #"needDescrip"];
NSURL *url = [[NSURL alloc] initWithString:[needs objectForKey:#"userImage"]];
[cell.imageProfPic setImageWithURL:url];
return cell;
}
It worked like a charm, and the tutorial was pretty helpful since I'm a rookie with AFNetworking.
I'm working on an iOS application where I want to have a vertical tableview with large-ish pictures of a user's friends. (200x200px, 100x100pt)
I have it working, but it is super slow! I can barely move the tableview at all!
How can I do this asynchronously and in an expedient manner?
This is my current code:
In viewDidload:
FBRequest* friendsRequest = [FBRequest requestForMyFriends];
[friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,
NSDictionary* result,
NSError *error)
{
self.friends = [result objectForKey:#"data"];
NSLog(#"Found: %u friends", (unsigned)self.friends.count);
[self.leftTableView reloadData];
[self.rightTableView reloadData];
}];
CellForRowAtIndexPath:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"Cell"];
if (!cell)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:#"Cell"];
cell.backgroundColor = [UIColor clearColor];
}
NSDictionary<FBGraphUser> *friend = [self.friends objectAtIndex:indexPath.row];
if (friend)
{
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:#"http://graph.facebook.com/%#/picture?width=200&height=200", friend.id]];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *image = [UIImage imageWithData:data];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.frame = CGRectMake(0, 4, 100, 100);
imageView.layer.cornerRadius = 50.0f;
imageView.clipsToBounds = YES;
[cell.contentView addSubview:imageView];
}
return cell;
}
It might be easier for you if you made a custom UITableViewCell, then you can place a UIView (instead of UIImageView) and in InterfaceBuilder give it the class FBProfilePictureView. Now, all you need to do is set the profileID property on that view, and the Facebook SDK will handle getting the profile picture for the profile with the provided id and displaying it.
Facebook SDK Reference
The UIImageView+AFNetworking class from AFNetworking Framework is one of the most used methods to do this. You can easy import this Framework to your project:
https://github.com/AFNetworking/AFNetworking
And use like this:
#import "UIImageView+AFNetworking.h"
NSDictionary<FBGraphUser> *friend = [self.friends objectAtIndex:indexPath.row];
if (friend)
{
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:#"http://graph.facebook.com/%#/picture?width=200&height=200", friend.id]];
UIImageView *imageView = [[UIImageView alloc] init];
imageView.frame = CGRectMake(0, 4, 100, 100);
imageView.layer.cornerRadius = 50.0f;
imageView.clipsToBounds = YES;
[imageView setImageWithURL:url];
[cell.contentView addSubview:imageView];
}
If you use [NSData dataWithContentsOfURL:url] the images will be fetched synchronous. Also when ever you scroll the table view they will be fetched again.
Use https://github.com/rs/SDWebImage for asynchronous image loading. It will also cache the images.
Download the files from EgoImageView. This link ask you to download a file. Unzip it. Add those file into your app. Import EgoImageView.h in your class. Change this code instead of your code. First time, it will take time to load. If you are converting URL as data, it will take long time.
if (friend)
{
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:#"http://graph.facebook.com/%#/picture?width=200&height=200", friend.id]];
UIImageView *imageView = [[UIImageView alloc] init];
[imageView setImageURL:url];
imageView.frame = CGRectMake(0, 4, 100, 100);
imageView.layer.cornerRadius = 50.0f;
imageView.clipsToBounds = YES;
[cell.contentView addSubview:imageView];
}
Hope, it helps you.
I have this very serious problem of scrolling the table.
Initially i used GCD for loading the image in Background and setting on table cell.
but the table was not scrolling smoothly.
So i used SDWebImage for that but then the same thing is happening.
Could anyone let me know the reason for this. Why the table Scrolling is not smooth as expected.
Please let me know your views as my app is waiting its release for the only same purpose.
Code :
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
NSString *CellIdentifier = #"Cell";
customCellForExhibitor *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
NSArray *xibPath = [[NSBundle mainBundle]loadNibNamed:#"customCellForExhibitor" owner:self options:nil];
for (id fileObject in xibPath)
{
cell = (customCellForExhibitor*)fileObject;
}
}
objDataModel = [parserDataContentArray objectAtIndex:indexPath.section];
cell.exhibitorNameLabel.text = [objDataModel exhibitorNameObjectClass];
cell.exhibitorText.text = [objDataModel exhibitorOfferObjectClass];
cell.exhibitorSponsorType.text = [objDataModel exhibitorSponsorTypeObjectClass];
[cell.exhibitorSponsorType setTextAlignment:NSTextAlignmentRight];
// #pragma mark GCD;
//
// NSString *ImageURL = [[parserDataContentArray objectAtIndex:indexPath.section] exhibitorImageObjectClass];
//// NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:ImageURL]];
//// cell.exhibitorImage.image = [UIImage imageWithData:imageData];
//
// dispatch_queue_t concurrentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
// //this will start the image loading in bg
// dispatch_async(concurrentQueue, ^{
// NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:ImageURL]];
//
// //this will set the image when loading is finished
// dispatch_async(dispatch_get_main_queue(), ^{
//
// cell.exhibitorImage.image = [UIImage imageWithData:imageData];
// [cell setNeedsDisplay];
//
// });
// });
NSString *ImageURL = [[parserDataContentArray objectAtIndex:indexPath.section] exhibitorImageObjectClass];
[cell.exhibitorImage setImageWithURL:[NSURL URLWithString:ImageURL]
placeholderImage:[UIImage imageNamed:#"placeholder.png"]];
if ([cell.exhibitorSponsorType.text isEqualToString:#"Gold"]) {
cell.exhibitorSponsorType.textColor = [UIColor colorWithRed:255/255.0 green:215/255.0 blue:0 alpha:1];
}
else if ([cell.exhibitorSponsorType.text isEqualToString:#"Silver"]){
cell.exhibitorSponsorType.textColor = [UIColor colorWithRed:192/255.0 green:192/255.0 blue:192/255.0 alpha:1];
}
else cell.exhibitorSponsorType.textColor = [UIColor colorWithRed:229/255.0 green:228/255.0 blue:226/255.0 alpha:1];
return cell;
}
Thank You
Best Regards.
Use lazy loading file instead here is the reference u can find it here along with demo how it is implemented.
https://stackoverflow.com/a/18032907/1305001
[cell addSubview:[self addViewWithURL:ImageURL NFrame:CGRectMake(0, 0, 50, 50)]];
add this method below cellForRow
-(UIView*)addViewWithURL:(NSString*)urlStr NFrame:(CGRect)rect
{
LazyLoad *lazyLoading;
lazyLoading = [[LazyLoad alloc] init];
[lazyLoading setBackgroundColor:[UIColor grayColor]];
[lazyLoading setFrame:rect];
[lazyLoading loadImageFromURL:[NSURL URLWithString:urlStr]];
return lazyLoading;
}
Set placeholder in LazyLoad.m file's init method as
-(id)init{
if (self==[super init]) {
[self setImage:[UIImage imageNamed:#"placeholder.png"]];
}
return self;
}
And change superClass of LazyLoad.h file to UIImageView from UIView as
#interface LazyLoad : UIImageView