Reputation: 2351
I have an array of images which I want to display as buttons in a table View. Currently I am using TTButton for showing those buttons. I have set the image using
[theButton setImage:imageUrl forState:UIControlStateNormal];
But once the image is downloaded, it is not showing up in the view. Can anyone help me out with this one?
Upvotes: 0
Views: 371
Reputation: 357
How are you initializing the button? Try using one of the styles, such as:
TTButton *imageButton = [TTButton buttonWithStyle:@"thumbView:"];
The styles tell the images where to go. If you don't specify a style then you won't get an image.
Upvotes: 1
Reputation: 2351
I am using TTThumbView for imitating the same. Hope that helps anyone who is trying the same.
Upvotes: 0
Reputation: 1433
Try this......
NSURL *url = [[NSURL alloc] initWithString:image];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
NSData *urlData = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:&response error:nil];
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:url]];
And then assign the image:
[theButton setImage:image forState:UIControlStateNormal];
Upvotes: 0