I am using UIview and added tableview.The api sending a data to show textfield in tableiveiw.I can show the textfield data in cell using coding bt the problem is when I scroll the tableview the text value is lost.
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 100;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return subIncidentArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = #"cellapi";
UITableViewCell *incidentCell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
NSInteger row = [indexPath row];
NSDictionary *dic = [subIncidentArray objectAtIndex:row];
if (incidentCell == nil)
incidentCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
if ([[dic objectForKey:#"TemplateType"] isEqual:#1]) {
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(20, 40, 300, 30)];
textField.delegate = self;
textField.tag = 1;
textField.text = self.contentOfTextField;
[incidentCell addSubview:textField];
textField.borderStyle = UITextBorderStyleRoundedRect;
textField.textColor = [UIColor grayColor];
if ([dic objectForKey:#"TextValue"] ==[NSNull null])
textField.text = [dic objectForKey:#""];
else
textField.text = [dic objectForKey:#"TextValue"];
}
return incidentCell;
}
I had the same error, first of all be shure that your subIncidentArray is not empty in cellForRowAtIndexPath.
Try to re-init data of this array in this method
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *incidentCell = [UITableViewCell alloc]init];
NSInteger row = [indexPath row];
NSDictionary *dic = [subIncidentArray objectAtIndex:row];
if ([[dic objectForKey:#"TemplateType"] isEqual:#1]) {
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(20, 40, 300, 30)];
textField.delegate = self;
textField.tag = 1;
textField.text = self.contentOfTextField;
[incidentCell addSubview:textField];
textField.borderStyle = UITextBorderStyleRoundedRect;
textField.textColor = [UIColor grayColor];
if ([dic objectForKey:#"TextValue"] ==[NSNull null])
textField.text = [dic objectForKey:#""];
else
textField.text = [dic objectForKey:#"TextValue"];
}
return incidentCell;
}
Try this this may work.
Try like this, it may work
UITableViewCell *incidentCell = [[UITableViewCell alloc]init];
Related
I am trying to display three sections (#"Accounts and Tasks", #"Life Events", #"More") and relevant content in an UITableView. I am creating a custom UILabel for each row and try to display text.
Here is my code below. My issue is, The third section instead of displaying third section contents "Social Media", #"About Hop, #"Settingsā, it is showing some first section contents and overlapping the text.
Could someone guide me to solve this please?
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
NSArray *arrTemp1 = [[NSArray alloc]initWithObjects:#"My Accounts",#"Transfers/Deposit",#"Pay Bills", #"Investment Center",#"Claims Center",#"Locators",#"Loan Calculator", nil];
NSArray *arrTemp2 = [[NSArray alloc]initWithObjects:#"Auto Circle",#"Home Circle",nil];
NSArray *arrTemp3 = [[NSArray alloc]initWithObjects:#"Social Media",#"About Hop", #"Settings", nil];
self.keys = [NSArray arrayWithObjects:#"Accounts and Tasks", #"Life Events", #"More", nil];
NSArray *values = [NSArray arrayWithObjects:arrTemp1, arrTemp2, arrTemp3, nil];
self.tableContents = [NSDictionary dictionaryWithObjects:values forKeys:keys];
NSLog(#"table %#",self.tableContents);
NSLog(#"table with Keys %#",[self.tableContents allKeys]);
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return [self.keys count];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return [self.keys objectAtIndex:section];
}
- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section {
NSArray *listData =[self.tableContents objectForKey:[self.keys objectAtIndex:section]];
return [listData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *SimpleTableIdentifier = #"SimpleTableIdentifier";
NSArray *listData =[self.tableContents objectForKey:[self.keys objectAtIndex:[indexPath section]]];
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
if(cell == nil) {
NSLog(#"listData: %#", listData);
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SimpleTableIdentifier];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(26, 4, 250, 30)];
label.text = [listData objectAtIndex:[indexPath row]];
label.backgroundColor = [UIColor clearColor];
[cell.contentView addSubview:label];
}
[cell setUserInteractionEnabled:YES];
UIImageView *imv = [[UIImageView alloc]initWithFrame:CGRectMake(3,2, 20, 25)];
imv.image=[UIImage imageNamed:#"SettingsMore"];
[cell.contentView addSubview:imv];
return cell;
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
....
UILabel *label;
if(cell == nil) {
label = [[UILabel alloc] initWithFrame:CGRectMake(26, 4, 250, 30)];
label.tag = 8888;
label.backgroundColor = [UIColor clearColor];
[cell.contentView addSubview:label];
}
label = (UILabel *)[cell.contentView viewWithTag:8888];
label.text = [listData objectAtIndex:[indexPath row]];
}
If you set label.text in if(cell == nil), the text will not get updated on reusing the cell.
My project is based on parsing xml data and adding it to array and display in respectives views,now my problem is am parsing xml and adding those objects it to nsmutablearray as shown below:
-(void)connectionDidFinishLoading:(NSURLConnection *)connection {
samplearray = [[NSMutableArray alloc]init];
xmlParserObject = [[NSXMLParser alloc] initWithData:webData];
[xmlParserObject setDelegate:self];
[xmlParserObject parse];
for (int i =0; i<[rssOutputData count]; i++) {
NewsList *log = [rssOutputData objectAtIndex:i];
feedid = log.id;
NSLog(#"%d",feedid);
Invit = log.newsletterdet;
NSLog(#"%#",Invit);
[samplearray addObject:log];
NSLog(#"Count Final %d",[self.samplearray count]);
}
[[self navigationController] tabBarItem].badgeValue = mycount2;
NSLog(#"%#",mycount2);
[tblView reloadData];
[connection release];
}
The Above prints Count Value as 2014-04-04 15:21:10.009 cftsversion1[3087:70b] Count Final 1
But when I call those Count in tableview methods, it prints 0 so I cannot load datas in tableview Here is the code I tried for tableview methods:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section == 0)
return [samplearray count];Prints 0 here
NSLog(#"Count %d",[samplearray count]); Prints 0 here
if (section == 1)
return 1;
return 0;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"eventCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
}
for (UIView *view in cell.contentView.subviews) {
[view removeFromSuperview];
}
if (indexPath.section == 0)
{
NewsList *msglist = [samplearray objectAtIndex:indexPath.row];
cell.textLabel.text = msglist.newsletterdet;
NSLog(#"%#",msglist.newsletterdet);
NSInteger stat = msglist.readflag;
if ([[SingleTonClass sinlgeTon].colorArray2 containsObject:[NSString stringWithFormat:#"%d",indexPath.row]] || stat == 1) {
cell.textLabel.textColor = [UIColor redColor];
}
else{
cell.textLabel.textColor = [UIColor greenColor];
}
cell.backgroundColor = [UIColor blackColor];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
if (indexPath.section == 1)
{
UIButton *viewmoreButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
viewmoreButton.frame = CGRectMake(200.0f, 5.0f, 80.0f, 30.0f);
[viewmoreButton setTitle:#"View More" forState:UIControlStateNormal];
[cell addSubview:viewmoreButton];
[viewmoreButton addTarget:self
action:#selector(viewMore:)
forControlEvents:UIControlEventTouchUpInside];
cell.backgroundColor = [UIColor blackColor];
[cell.contentView addSubview:viewmoreButton];
}
return cell;
}
When run the above tableview code section 0 is not at all loading because array count prints 0 only section 1 is loading please help me how to solve this issue Thanks in advance
Intialize sampleArray in ViewDidLoad
samplearray = [[NSMutableArray alloc]init]
Make sure [tblView reloadData] is working properly.Initialy table will be loaded before completion of connectionDidFinishLoading, so count will be 0. Only in reload the count increments.
I have doubt you are printing value in wrong way. Try to print it correctly first and update us:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section == 0)
{
NSLog(#"Count %d",[samplearray count]);\\ Prints 0 here
return [samplearray count];\\Prints 0 here
}
else if (section == 1)
{
return 1;
}
return 0;
}
and declare your NSMutableArray in .h file like:
#property (nonatomic, strong) NSMutableArray *samplearray;
I am creating multiple lists like questions and answer session, question with multiple answers in table rows. But whenever I select a row other questions answers are also get selected and when I came back to same all the selections are gone. So how to avoid this ? Please help.
my code is,
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if(val==1)
{
checkedArr=[[NSMutableArray alloc] init];
for (int i = 0; i<17; i++)
{
[checkedArr addObject:#"1"];
}
NSLog(#"Checked arr size %i",[checkedArr count]);
return 17;
}
else if(val==2)
{
checkedArr=[[NSMutableArray alloc] init];
for (int i = 0; i<13; i++)
{
[checkedArr addObject:#"1"];
}
return 13;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier = [NSString stringWithFormat:#"Cell%i",indexPath.row];
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell==nil)
{
cell= [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.textLabel.numberOfLines = 0;
cell.textLabel.font = [UIFont fontWithName:#"Helvetica" size:14.0];
}
cell.textLabel.font = [UIFont fontWithName:#"Helvetica-Bold" size:18.0];
UIView *selectionColor = [[UIView alloc] init];
selectionColor.backgroundColor = [UIColor colorWithRed:99/255.0f green:209/255.0f blue:248/255.0f alpha:1.0];
cell.selectedBackgroundView = selectionColor;
if([[checkedArr objectAtIndex:indexPath.row] isEqual:#"0"])
{
cell.accessoryView=[[UIImageView alloc] initWithImage:[UIImage imageNamed:#"tick.png"]];
[checkedArr addObject:indexPath];
NSLog(#"checkedArr 0000000");
}
else if ([[checkedArr objectAtIndex:indexPath.row] isEqual:#"1"])
{
cell.accessoryView.hidden=TRUE;
//cell.accessoryView=Nil;
[checkedArr removeObject:indexPath];
NSLog(#"checkedArr 111111");
}
cell.textLabel.frame=CGRectMake(75.0, 50.0, 150.0, 20.0);
cell.textLabel.text=[listArray objectAtIndex:indexPath.row];
NSLog(#"Checked arr size %i",[checkedArr count]);
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
cell=[questionTable cellForRowAtIndexPath:indexPath];
[checkedArr replaceObjectAtIndex:indexPath.row withObject:#"0"];
if([[checkedArr objectAtIndex:indexPath.row] isEqual:#"0"])
{
cell.accessoryView=[[UIImageView alloc] initWithImage:[UIImage imageNamed:#"tick.png"]];
[checkedArr addObject:indexPath];
NSLog(#"checkedArr 0000000");
}
else if ([[checkedArr objectAtIndex:indexPath.row] isEqual:#"1"])
{
cell.accessoryView=nil;
[checkedArr removeObject:indexPath];
NSLog(#"checkedArr 111111");
}
[questionTable deselectRowAtIndexPath:indexPath animated:YES];
//[self.questionTable reloadData];
NSLog(#"Val is %i",val);
NSLog(#"selected is %#",[listArray objectAtIndex:indexPath.row]);
// NSLog(#"Checked arr descripton %#",[checkedArr description]);
}
-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.accessoryView = nil;
}
When using reloading with indexpaths or indexsets the _recordLabel and _dateLabel are shown, and then not shown, and it repeats again. Im using the debug paint layers and its nowhere around. But if use reload data everything seems fine. I don't know why is that happening.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellIdentifier;
cellIdentifier = [_sections objectAtIndex:indexPath.section];
XFitGroupCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (!cell) {
cell = [[XFitGroupCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
[self stampCell:cell atIndexPath:indexPath];
}
[self configureCell:cell atIndexPath:indexPath];
return cell;
}
- (void)stampCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath
{
if ([cell.reuseIdentifier isEqualToString:#"exerciseDescriptionCell"]) {
if (!_textView) {
_textView = [[UITextView alloc] initWithFrame:CGRectMake(0.f, 22.f, cell.frame.size.width, 66.f)];
}
_textView.editable = NO;
_textView.font = [UIFont fontWithName:#"Avenir-Light" size:14.f];
[cell.contentView addSubview:_textView];
}
else if ([cell.reuseIdentifier isEqualToString:#"exerciseResultsCell"]) {
UILabel *recordLabelTag = [[UILabel alloc] initWithFrame:CGRectMake(10.f, 28.f, 55.f, 14.f)];
if ([_exercise.eType.name isEqualToString:#"Strength"]) {
recordLabelTag.text = #"PR";
}
else {
recordLabelTag.text = #"UB";
}
recordLabelTag.font = [UIFont fontWithName:#"Avenir-Heavy" size:14.f];
recordLabelTag.textAlignment = NSTextAlignmentCenter;
[cell.contentView addSubview:recordLabelTag];
if (!_recordLabel) {
_recordLabel = [[UILabel alloc] initWithFrame:CGRectMake(10.f, 48.f, 55.f, 12.f)];
}
_recordLabel.font = [UIFont fontWithName:#"Avenir-Light" size:12.f];
_recordLabel.textAlignment = NSTextAlignmentCenter;
[cell.contentView addSubview:_recordLabel];
UILabel *dateLabelTag = [[UILabel alloc] initWithFrame:CGRectMake(70.f, 28.f, 55.f, 14.f)];
dateLabelTag.text = #"Date";
dateLabelTag.font = [UIFont fontWithName:#"Avenir-Heavy" size:14.f];
dateLabelTag.textAlignment = NSTextAlignmentCenter;
[cell.contentView addSubview:dateLabelTag];
if (!_dateLabel) {
_dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(70.f, 48.f, 55.f, 12.f)];
}
_dateLabel.font = [UIFont fontWithName:#"Avenir-Light" size:12.f];
_dateLabel.textAlignment = NSTextAlignmentCenter;
[cell.contentView addSubview:_dateLabel];
UIButton *recordButton = [[UIButton alloc] initWithFrame:CGRectMake(cell.frame.size.width - 73.f, 30.f, 65.f, 28.f)];
recordButton.backgroundColor = [UIColor colorWithRed:77.f/255.f green:123.f/255.f blue:209.f/255.f alpha:1.f];
recordButton.layer.cornerRadius = 4.f;
[recordButton addTarget:self action:#selector(addRecord) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:recordButton];
UILabel *newPRLabel = [[UILabel alloc] initWithFrame:CGRectMake(5.f, 7.f, 55.f, 14.f)];
if ([_exercise.eType.name isEqualToString:#"Strength"]) {
newPRLabel.text = #"New PR";
}
else {
newPRLabel.text = #"New UB";
}
newPRLabel.textColor = [UIColor whiteColor];
newPRLabel.font = [UIFont fontWithName:#"Avenir-Book" size:14.f];
[recordButton addSubview:newPRLabel];
UIButton *showAllButton = [[UIButton alloc] initWithFrame:CGRectMake(cell.frame.size.width - 73.f - 75.f, 30.f, 65.f, 28.f)];
showAllButton.backgroundColor = [UIColor colorWithRed:98.f/255.f green:233.f/255.f blue:126.f/255.f alpha:1.f];
showAllButton.layer.cornerRadius = 4.f;
[cell.contentView addSubview:showAllButton];
UILabel *showAllLabel = [[UILabel alloc] initWithFrame:CGRectMake(5.f, 7.f, 55.f, 14.f)];
showAllLabel.text = #"Show All";
showAllLabel.textColor = [UIColor whiteColor];
showAllLabel.font = [UIFont fontWithName:#"Avenir-Book" size:14.f];
[showAllButton addSubview:showAllLabel];
}
}
- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath
{
if ([cell.reuseIdentifier isEqualToString:#"exerciseDescriptionCell"]) {
[(XFitGroupCell *)cell setText:#"Description"];
[(XFitGroupCell *)cell setImage:[UIImage imageNamed:#"descriptionIcon"]];
_textView.text = _exercise.overview;
}
else if ([cell.reuseIdentifier isEqualToString:#"exerciseResultsCell"]) {
[(XFitGroupCell *)cell setText:#"Previous Results"];
[(XFitGroupCell *)cell setImage:[UIImage imageNamed:#"recordIcon"]];
ExerciseRecord *personalRecord = _exercise.personalRecord;
NSLog(#"Received: %#\n", personalRecord.score);
_recordLabel.text = [personalRecord.score stringValue];
NSLog(#"Text : %#\n", _recordLabel.text);
_dateLabel.text = [_dateFormatter stringFromDate:personalRecord.date];
}
}
#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
return 88.f;
}
else if (indexPath.section == 1) {
return 66.f;
}
return 0.f;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 15.f;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 7.f;
}
#pragma mark - UIAlertViewDelegate
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (alertView.tag == 1) {
if (buttonIndex == 1) {
ExerciseRecord *eRecord = [NSEntityDescription insertNewObjectForEntityForName:#"ExerciseRecord" inManagedObjectContext:_managedObjectContext];
eRecord.score = [NSNumber numberWithInt:[[alertView textFieldAtIndex:0].text intValue]];
eRecord.date = [NSDate date];
eRecord.exercise = _exercise;
NSError *error;
if (![_managedObjectContext save:&error]) {
NSLog(#"%# %#", error, [error userInfo]);
abort();
}
[_tableView reloadData];
//[_tableView beginUpdates];
//[_tableView reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationFade];
//[_tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:0 inSection:1]] withRowAnimation:UITableViewRowAnimationFade];
//[_tableView endUpdates];
}
}
}
I am not sure why this isn't working, but from my experience I'd recommend you use a framework while working with Core Data instead of doing all the work manually yourself. I personally use the Sensible TableView framework, which automatically fetches my data and displays it in table views. It also handles all entity relationships and auto creates the detail views for them. Saves me tons of development time when working on Core Data projects. HTH.
I have a bug.
I want to display a UIImageView on cells at special indexPath.row, but these UIImageView repeat while I scroll.
Exemple: I display my UIImageView on a cell indexPath.row == 0, if I scroll down, I see my UIImageView on the cell at indexPath.row == 8.
Here is my code:
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil) {
cell = [self getCellContentView:CellIdentifier];
}
UILabel *lblTemp1 = (UILabel *)[cell viewWithTag:1];
UIImageView *imgRead = (UIImageView *)[cell viewWithTag:6];
[cell.contentView insertSubview:imgRead aboveSubview:lblTemp1];
contentDictio = [dict objectAtIndex:indexPath.row];
lblTemp1.text = [contentDictio objectForKey:#"title"];
NSArray *paths_id = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *basePath_id = ([paths_id count] > 0) ? [paths_id objectAtIndex:0] : nil;
NSString *path_id = [basePath_id stringByAppendingPathComponent:#"id.plist"];
NSMutableArray *mut_array_id = [[NSArray arrayWithContentsOfFile:path_id] mutableCopy];
NSMutableDictionary *c0 = [[NSMutableDictionary alloc] init];
NSString *idPlistData = [contentDictio objectForKey:#"id"];
for(c0 in mut_array_id) {
if([[c0 objectForKey:#"id"] isEqualToString:idPlistData]) {
[imgRead setImage:[UIImage imageNamed:#"read"]];
}
else {
}
}
}
return cell;
}
- (UITableViewCell *) getCellContentView:(NSString *)cellIdentifier {
CGRect Label1Frame = CGRectMake(kTableCellSmallMargin*2 + 60, kTableCellSmallMargin, 240, 25);
UILabel *lblTemp;
UITableViewCell *cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:cellIdentifier] autorelease];
//Initialize Label with tag 1.
lblTemp = [[UILabel alloc] initWithFrame:Label1Frame];
lblTemp.tag = 1;
lblTemp.backgroundColor = [UIColor clearColor];
[lblTemp setFont: [UIFont fontWithName:#"HelveticaNeue-CondensedBold" size:15.0]];
[cell.contentView addSubview:lblTemp];
[lblTemp release];
UIImageView *read=[[UIImageView alloc] initWithFrame:CGRectMake(kTableCellSmallMargin, kTableCellSmallMargin, 60, 60)];
read.backgroundColor=[UIColor clearColor];
read.tag = 6;
[cell.contentView addSubview:read];
[read release];
return cell;
}
Thanks...
The cell is cached, so you have to clear it when you want no image, like this:
BOOL found = NO;
for(c0 in mut_array_id) {
if([[c0 objectForKey:#"id"] isEqualToString:idPlistData]) {
[imgRead setImage:[UIImage imageNamed:#"read"]];
found = YES;
}
else {
}
}
if (!found)
{
[imgRead setImage:nil];
}