i am parsing two xml files 开发者_如何学运维with one xml parser class , i have a table view where the data is displaying after parsing .. here is a imageview and label , when i parse the first xml like if i parse myxml_1.xml
and then display data in a table view its fine . but when i parse again the xml named myxml_2.xml
and display the data in that table view its displaying uilabel fine but the image is not displaying properly it always display the images that i have in my first xml ..
i have used mytableview.reloadData...but Still have a problem . here is a code placed in cellforrowatindexpath ..
///its a label///
labelView = [[UILabel alloc] initWithFrame: CGRectMake(12, 0, 300, 44)];
[labelView setBackgroundColor:[UIColor clearColor]];
//[labelView setShadowColor:[UIColor whiteColor]];
[labelView setFont:[UIFont fontWithName:@"Arial" size:13.0]];
[labelView setTextColor:[UIColor whiteColor]];
[labelView setTag:223];
[cell addSubview:labelView];
[labelView release];
///working fine ///
///this is for imageview////
NSURL *url = [NSURL URLWithString:newimage];
NSData *imgData = [NSData dataWithContentsOfURL:url];
UIImage *image = [UIImage imageWithData:imgData];
[cell.imageView setImage:image];
///Not Working ///
Your help will be appreciated..! Thanks.
One big problem with what you are showing here is that you are loading data synchronously inside a cellForRow:atIndexPath: method of UITableViewController. That method gets called every time a tableview is created to show on the screen. If a user is scrolling your view up and down, the method gets called every time a cell leaves and comes back on screen.
To try to narrow dow the problem you have mentioned, I would first try to nil out the old image, and then assert that there is actually data in the new one before you set it.
精彩评论