ios6, UITableViewCell background - uitableview

I have a trouble with ios6 and UITableViewCell. The backgroundcolor is not set, this is what it used to work in ios5
-(UITableViewCell *)tableView:(UITableView *) tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = nil;
NSString *contentForThisRow = [[self myArray] objectAtIndex:[indexPath row]];
cell = [tableView dequeueReusableCellWithIdentifier:#"noticeCell"];
if(cell == nil){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:#"noticeCell"];
}
cell.textLabel.text = contentForThisRow;
id path = [NSString stringWithFormat:#"myip%#.jpeg", IDimage];
NSURL *url = [NSURL URLWithString:path];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc] initWithData:data];
cell.imageView.image = img;
cell.textLabel.font = [UIFont fontWithName:#"Helvetica" size:15.0];
UIColor *cellBackground = [UIColor colorWithRed:235.0/255.0 green:245.0/255.0 blue:255.0/255.0 alpha:0.25];
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
[cell setBackgroundColor:cellBackground];
return cell;
}
but now I'm not able to set it again!
How should I do this?
Thanks!

Use
cell.contentView.backgroundColor= [UIColor blueColor];
you may use clear color for cell textlabel background.
It should work.
:)

Related

Reloading UITableView causes incorrect setting of labels

When my UITableView loads for the first time, everything in the code below functions correctly. However, if it reloads for whatever reason (refresh, etc.), it starts assigning a cell.bestMatchLabel.text value of #"Best Match" to random cells, rather than only the first one as I specified in the code. Why is calling reload on my table causing the below code to not run correctly?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//load top 3 data
NSDictionary *currentSectionDictionary = _matchCenterArray[indexPath.section];
NSArray *top3ArrayForSection = currentSectionDictionary[#"Top 3"];
// if no results for that item
if (top3ArrayForSection.count-1 < 1) {
// Initialize cell
static NSString *CellIdentifier = #"MatchCenterCell";
EmptyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
// if no cell could be dequeued create a new one
cell = [[EmptyTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
// title of the item
cell.textLabel.text = #"No items found, but we'll keep a lookout for you!";
cell.textLabel.font = [UIFont systemFontOfSize:12];
cell.detailTextLabel.text = [NSString stringWithFormat:#""];
[cell.imageView setImage:[UIImage imageNamed:#""]];
return cell;
}
// if results for that item found
else {
// Initialize cell
static NSString *CellIdentifier = #"MatchCenterCell";
MatchCenterCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
// if no cell could be dequeued create a new one
cell = [[MatchCenterCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
tableView.separatorColor = [UIColor clearColor];
if (indexPath.row == 0) {
cell.bestMatchLabel.text = #"Best Match";
cell.bestMatchLabel.font = [UIFont systemFontOfSize:12];
cell.bestMatchLabel.textColor = [UIColor colorWithRed:0.18 green:0.541 blue:0.902 alpha:1];
[cell.contentView addSubview:cell.bestMatchLabel];
}
// title of the item
cell.textLabel.text = _matchCenterArray[indexPath.section][#"Top 3"][indexPath.row+1][#"Title"];
cell.textLabel.font = [UIFont systemFontOfSize:14];
// price + condition of the item
NSString *price = [NSString stringWithFormat:#"$%#", _matchCenterArray[indexPath.section][#"Top 3"][indexPath.row+1][#"Price"]];
NSString *condition = [NSString stringWithFormat:#"%#", _matchCenterArray[indexPath.section][#"Top 3"][indexPath.row+1][#"Item Condition"]];
cell.detailTextLabel.text = [NSString stringWithFormat:#"%# - %#", price, condition];
cell.detailTextLabel.textColor = [UIColor colorWithRed:0.384 green:0.722 blue:0.384 alpha:1];
// Load images using background thread to avoid the laggy tableView
[cell.imageView setImage:[UIImage imageNamed:#"Placeholder.png"]];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
// Download or get images here
NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:_matchCenterArray[indexPath.section][#"Top 3"][indexPath.row+1][#"Image URL"]]];
// Use main thread to update the view. View changes are always handled through main thread
dispatch_async(dispatch_get_main_queue(), ^{
// Refresh image view here
[cell.imageView setImage:[UIImage imageWithData:imageData]];
cell.imageView.layer.masksToBounds = YES;
cell.imageView.layer.cornerRadius = 2.5;
[cell setNeedsLayout];
});
});
return cell;
}
}
That is because table dequeue same cell for multiple indexes as you scroll down, so you need to add else statement in the following code
if (indexPath.row == 0) {
cell.bestMatchLabel.text = #"Best Match";
cell.bestMatchLabel.font = [UIFont systemFontOfSize:12];
cell.bestMatchLabel.textColor = [UIColor colorWithRed:0.18 green:0.541 blue:0.902 alpha:1];
[cell.contentView addSubview:cell.bestMatchLabel];
[cell.bestMatchLabel setHidden:NO];
} else {
[cell.bestMatchLabel setHidden:YES];
}
but a better approach for this case is to use different cell identifier for that row and only add the bestMatchLabel once when first creating the cell

How to set a Bool value to be different for each UITableView Section

What I want to do here is set it so that if top3ArrayForSection.count-1 < 1, set the _results bool value of that respective section to NO, and so on. What's happening instead, is that _results is set to NO or YES for the entire table overall, so that I end up with a result like this:
When only the "xperia Z3 compact unlocked" section should say "no items found etc." because it has no cells, the other sections cells shouldn't.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSDictionary *currentSectionDictionary = _matchCenterArray[section];
NSArray *top3ArrayForSection = currentSectionDictionary[#"Top 3"];
if (top3ArrayForSection.count-1 < 1){
_results = NO;
_rowCount = 1;
}
else if(top3ArrayForSection.count-1 >= 1){
_results = YES;
_rowCount = top3ArrayForSection.count-1;
}
return _rowCount;
}
// Cell layout
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// Initialize cell
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
// if no cell could be dequeued create a new one
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
// No cell seperators = clean design
tableView.separatorColor = [UIColor clearColor];
if (_results == NO) {
// title of the item
cell.textLabel.text = #"No items found, but we'll keep a lookout for you!";
cell.textLabel.font = [UIFont boldSystemFontOfSize:12];
}
else if (_results == YES) {
// title of the item
cell.textLabel.text = _matchCenterArray[indexPath.section][#"Top 3"][indexPath.row+1][#"Title"];
cell.textLabel.font = [UIFont boldSystemFontOfSize:14];
// price of the item
cell.detailTextLabel.text = [NSString stringWithFormat:#"$%#", _matchCenterArray[indexPath.section][#"Top 3"][indexPath.row+1][#"Price"]];
cell.detailTextLabel.textColor = [UIColor colorWithRed:0/255.0f green:127/255.0f blue:31/255.0f alpha:1.0f];
// image of the item
NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:_matchCenterArray[indexPath.section][#"Top 3"][indexPath.row+1][#"Image URL"]]];
[[cell imageView] setImage:[UIImage imageWithData:imageData]];
}
return cell;
}
Your instance variable _results is one-dimensional. You could replace it with an NSArray and store the values individually, or you could change the logic in your code as such:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSDictionary *currentSectionDictionary = _matchCenterArray[section];
NSArray *top3ArrayForSection = currentSectionDictionary[#"Top 3"];
return (top3ArrayForSection.count-1 < 1) ? 1 : top3ArrayForSection.count-1;
}
// Cell layout
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// Initialize cell
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
// if no cell could be dequeued create a new one
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
// No cell seperators = clean design
tableView.separatorColor = [UIColor clearColor];
NSDictionary *currentSectionDictionary = _matchCenterArray[indexPath.section];
NSArray *top3ArrayForSection = currentSectionDictionary[#"Top 3"];
if (top3ArrayForSection.count-1 < 1) {
// title of the item
cell.textLabel.text = #"No items found, but we'll keep a lookout for you!";
cell.textLabel.font = [UIFont boldSystemFontOfSize:12];
}
else {
// title of the item
cell.textLabel.text = _matchCenterArray[indexPath.section][#"Top 3"][indexPath.row+1][#"Title"];
cell.textLabel.font = [UIFont boldSystemFontOfSize:14];
// price of the item
cell.detailTextLabel.text = [NSString stringWithFormat:#"$%#", _matchCenterArray[indexPath.section][#"Top 3"][indexPath.row+1][#"Price"]];
cell.detailTextLabel.textColor = [UIColor colorWithRed:0/255.0f green:127/255.0f blue:31/255.0f alpha:1.0f];
// image of the item
NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:_matchCenterArray[indexPath.section][#"Top 3"][indexPath.row+1][#"Image URL"]]];
[[cell imageView] setImage:[UIImage imageWithData:imageData]];
}
return cell;
}

UIImage is showing on simulator, not on a real device

I have tried all of the suggestions in other similarly titled questions. My case seems to be special. Here's my code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([tableView respondsToSelector:#selector(setSeparatorInset:)]) {
[tableView setSeparatorInset:UIEdgeInsetsZero];
}
NSString *cellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if ([menu_List count] == 0){
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
NSString *newString = [[MainMenuArray objectAtIndex:indexPath.row] stringByReplacingOccurrencesOfString:#" " withString:#""];
UIImage *image1 = [UIImage imageNamed:[NSString stringWithFormat:#"%#%#", newString,#".png"]];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image1];
[imageView setFrame:CGRectMake(5.0, 1.0, 41.0, 41.0)];
[imageView setContentMode:UIViewContentModeScaleAspectFill];
[cell addSubview:imageView];
cell.textLabel.textColor = [UIColor whiteColor];
GetData *GD = [[GetData alloc] init];
cell.backgroundColor = [GD colorWithHexString:#"18204a"];
cell.textLabel.text = [NSString stringWithFormat:#"%#", [MainMenuArray objectAtIndex:indexPath.row]];
}else{
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
cell.textLabel.text = [NSString stringWithFormat:#"%#", [menu_List objectAtIndex:indexPath.row]];
cell.textLabel.textColor = [UIColor whiteColor];
GetData *GD = [[GetData alloc] init];
cell.backgroundColor = [GD colorWithHexString:#"18204a"];
}
return cell;
}
So the string name is correct, and it matches the case. I've checked my build settings, and the images are in copy bundle resources. All show up in the simulator. Only two of the seven appear in the list. If I change the order in which they appear, it is still the same two images that show up. They all show up in the simulator. I am using ECSlidingViewController to create a menu and I want the images to show up. Any idea on what could be causing it?
Clean your project and check for upper case letters. Simulator is not case sensitive, but real devices does not load an image if you use "myimage.png" on your code but your image name is MyImage.png
Make sure your png is enabled for the schema

Change background cell in tableView permanently after selected

How can I change the background cell permanently after being selected? What I know is by using cell.selectedBackgroundView it will only change the cell background for a while and then it goes back to normal.
I want it to change permanently when selected even after app are closed. I tried to search for a solution but could not find relevant answer.
this is my cellForRowAtIndexPath method:
- (UITableViewCell *)tableView:(UITableView *)tableView2 cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView2 dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]autorelease];
//set up selected cell background
cell.backgroundView = [ [[UIImageView alloc] initWithImage:[ [UIImage imageNamed:#"white_selected.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0] ]autorelease];
cell.selectedBackgroundView = [ [[UIImageView alloc] initWithImage:[ [UIImage imageNamed:#"blue_selected.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0] ]autorelease];
}
//set up cell
CGFloat nRed= 0/255.0;
CGFloat nGreen=73.0/255.0;
CGFloat nBlue=144.0/255.0;
UIColor *myColor=[[UIColor alloc]initWithRed:nRed green:nGreen blue:nBlue alpha:1];
//set up cell text
cell.textLabel.text = [[AryStoreknowItem objectAtIndex:indexPath.row] objectForKey:#"title"];
cell.textLabel.highlightedTextColor = [UIColor colorWithRed:51.0f/255.0f green:102.0f/255.0f blue:153.0f/255.0f alpha:1.0f];
cell.textLabel.font=[UIFont fontWithName:#"HelveticaNeue-Bold" size:15];
cell.textLabel.textColor=myColor;
cell.backgroundColor = [UIColor colorWithRed: 0.0 green: 0.0 blue: 0.2 alpha: 1.0];
//set icon image for cell
cell.imageView.image = [UIImage imageNamed:
[[AryStoreknowItem objectAtIndex:indexPath.row] objectForKey:#"icon"]];
return cell;
}
below are my didSelectRowAtIndexPath method;
- (void)tableView:(UITableView *)tableView2 didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
indexPath];
[self->tableView deselectRowAtIndexPath:indexPath animated:YES];
if ([[[AryStoreknowItem objectAtIndex:indexPath.row] objectForKey:#"action"] isEqualToString:#"a1"]){
NSString *title_a1 =[[AryStoreknowItem objectAtIndex:indexPath.row] objectForKey:#"title"];
NSString *content_a1 = [[AryStoreknowItem objectAtIndex:indexPath.row] objectForKey:#"content"];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
// saving an NSString
[defaults setObject:title_a1 forKey:#"title_a1"];
[defaults setObject:content_a1 forKey:#"content_a1"];
WebBrowserViewController *webview=[[WebBrowserViewController alloc]initWithNibName:#"WebBrowserViewController" bundle:nil];
[self presentModalViewController:webview animated:YES];
}else if ([[[AryStoreknowItem objectAtIndex:indexPath.row] objectForKey:#"action"] isEqualToString:#"a2"]){
NSString *title_a2 =[[AryStoreknowItem objectAtIndex:indexPath.row] objectForKey:#"title"];
NSString *content_a2 = [[AryStoreknowItem objectAtIndex:indexPath.row] objectForKey:#"content"];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
// saving an NSString
[defaults setObject:title_a2 forKey:#"title_a2"];
[defaults setObject:content_a2 forKey:#"content_a2"];
WebBrowserViewController *webview=[[WebBrowserViewController alloc]initWithNibName:#"WebBrowserViewController" bundle:nil];
[self presentModalViewController:webview animated:YES];
}else {
NSLog(#" other action key get! ");
}
}
You can add one property to your datasource array, for example, named BOOL isSelected.
in - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath you update isSelected = YES. and add the following
[tableView beginUpdates];
[tableView reloadRowsAtIndexPaths:#[indexPath] withRowAnimation:UITableViewRowAnimationNone];
[tableView endUpdates];
to update the selected cell. and in your - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath method
if(data.isSelected){
cell.backgroundView = [[UIImageView alloc] initWithImage:[ [UIImage imageNamed:#"blue_selected.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0] ];
}
the code is here:
You need add one bool property to the object in your array. For example,you add
#property (nonatomic) BOOL isSelected; to your object class's header file.
- (UITableViewCell *)tableView:(UITableView *)tableView2 cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView2 dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]autorelease];
//set up selected cell background
//cell.backgroundView = [ [[UIImageView alloc] initWithImage:[ [UIImage imageNamed:#"white_selected.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0] ]autorelease];
//cell.selectedBackgroundView = [ [[UIImageView alloc] initWithImage:[ [UIImage imageNamed:#"blue_selected.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0] ]autorelease];
}
if (((YourObjectType *)[AryStoreknowItem objectAtIndex:indexPath.row]).isSelected){
cell.backgroundView = [ [[UIImageView alloc] initWithImage:[ [UIImage imageNamed:#"blue_selected.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0] ]autorelease];
} else {
cell.backgroundView = [ [[UIImageView alloc] initWithImage:[ [UIImage imageNamed:#"white_selected.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0] ]autorelease];
}
//set up cell
CGFloat nRed= 0/255.0;
CGFloat nGreen=73.0/255.0;
CGFloat nBlue=144.0/255.0;
UIColor *myColor=[[UIColor alloc]initWithRed:nRed green:nGreen blue:nBlue alpha:1];
//set up cell text
cell.textLabel.text = [[AryStoreknowItem objectAtIndex:indexPath.row] objectForKey:#"title"];
cell.textLabel.highlightedTextColor = [UIColor colorWithRed:51.0f/255.0f green:102.0f/255.0f blue:153.0f/255.0f alpha:1.0f];
cell.textLabel.font=[UIFont fontWithName:#"HelveticaNeue-Bold" size:15];
cell.textLabel.textColor=myColor;
cell.backgroundColor = [UIColor colorWithRed: 0.0 green: 0.0 blue: 0.2 alpha: 1.0];
//set icon image for cell
cell.imageView.image = [UIImage imageNamed:
[[AryStoreknowItem objectAtIndex:indexPath.row] objectForKey:#"icon"]];
return cell;
}
- (void)tableView:(UITableView *)tableView2 didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
indexPath];
[self->tableView deselectRowAtIndexPath:indexPath animated:YES];
((YourObjectType *)[AryStoreknowItem objectAtIndex:indexPath.row]).isSelected = YES;
[tableView beginUpdates];
[tableView reloadRowsAtIndexPaths:#[indexPath] withRowAnimation:UITableViewRowAnimationNone];
[tableView endUpdates];
if ([[[AryStoreknowItem objectAtIndex:indexPath.row] objectForKey:#"action"] isEqualToString:#"a1"]){
NSString *title_a1 =[[AryStoreknowItem objectAtIndex:indexPath.row] objectForKey:#"title"];
NSString *content_a1 = [[AryStoreknowItem objectAtIndex:indexPath.row] objectForKey:#"content"];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
// saving an NSString
[defaults setObject:title_a1 forKey:#"title_a1"];
[defaults setObject:content_a1 forKey:#"content_a1"];
WebBrowserViewController *webview=[[WebBrowserViewController alloc]initWithNibName:#"WebBrowserViewController" bundle:nil];
[self presentModalViewController:webview animated:YES];
}else if ([[[AryStoreknowItem objectAtIndex:indexPath.row] objectForKey:#"action"] isEqualToString:#"a2"]){
NSString *title_a2 =[[AryStoreknowItem objectAtIndex:indexPath.row] objectForKey:#"title"];
NSString *content_a2 = [[AryStoreknowItem objectAtIndex:indexPath.row] objectForKey:#"content"];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
// saving an NSString
[defaults setObject:title_a2 forKey:#"title_a2"];
[defaults setObject:content_a2 forKey:#"content_a2"];
WebBrowserViewController *webview=[[WebBrowserViewController alloc]initWithNibName:#"WebBrowserViewController" bundle:nil];
[self presentModalViewController:webview animated:YES];
}else {
NSLog(#" other action key get! ");
}
}

We using this Asyncimageview classes to get image from web serves and showing in UItableview but is not working?

//UITableView
NSString *data_image;
data_image = [[message_array objectAtIndex:indexPath.row] valueForKey:#"img_thumb"];
NSLog(#"data_image---%#",data_image);
if (![data_image isEqualToString:#""])
{
img_bubble = [[UIImageView alloc]initWithImage:cloudImage];
[img_bubble setFrame:CGRectMake(225, 0,85 , 80)];
img_buble_sender = [[UIImageView alloc]initWithImage:cloudImage1];
[img_buble_sender setFrame:CGRectMake(10,0,90,80)];
urlImage = [NSURL URLWithString:[[message_array objectAtIndex:indexPath.row] valueForKey:#"image"]];
asyncImage = [[AsyncImageView alloc]initWithFrame:CGRectMake(238, 10, 55, 55)];
[asyncImage loadImageFromURL:urlImage];
//images1=[[UIImageView alloc]initWithFrame:CGRectMake(238, 10,55 , 55)];
//[images1 setImageWithURL:urlImage];
}
Try this in your cellForRowAtIndexPath:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
//create new cell
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
//common settings
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
cell.imageView.contentMode = UIViewContentModeScaleAspectFill;
cell.imageView.frame = CGRectMake(238, 10, 55, 55);
cell.imageView.clipsToBounds = YES;
}
else {
//cancel loading previous image for cell
[[AsyncImageLoader sharedLoader] cancelLoadingImagesForTarget:cell.imageView];
}
//set placeholder image or cell won't update when image is loaded
cell.imageView.image = [UIImage imageNamed:#"Placeholder.png"];
//load the image
cell.imageView.imageURL = [NSURL URLWithString:[[message_array objectAtIndex:indexPath.row];
return cell;
}
I'm not sure about which AsyncImageView you are using, but you could try this:
//UITableView
NSString *data_image;
data_image = [[message_array objectAtIndex:indexPath.row] valueForKey:#"img_thumb"];
NSLog(#"data_image---%#",data_image);
if (![data_image isEqualToString:#""])
{
img_bubble = [[UIImageView alloc]initWithImage:cloudImage];
[img_bubble setFrame:CGRectMake(225, 0,85 , 80)];
img_buble_sender = [[UIImageView alloc]initWithImage:cloudImage1];
[img_buble_sender setFrame:CGRectMake(10,0,90,80)];
urlImage = [NSURL URLWithString:[[message_array objectAtIndex:indexPath.row] valueForKey:#"image"]];
asyncImage = [[AsyncImageView alloc]initWithFrame:CGRectMake(238, 10, 55, 55)];
[asyncImage loadImageFromURL:urlImage];
[cell.contentView addSubview:asyncImage];
}

Resources