UITableView reloading data / refreshing (possible duplication issue)?

You're right, it is creating a new instance of the UISegmentedControl. It's because you are using a generic cell identifier, @"Cell", then adding the UISegmentedControl each time, never removing it. The cells get cached containing the UISegmentedControl, you retrieve the cached cell and add the control again You could use a more specific cell identifier and if cell!

= nil you know it contains the UISegmentedControl already. Or create a new cell each time that way you're not using a cached cell that already contains the control With the image view you just set the cells image view property without adding a new view to the cell so that one is ok, it gets replaced each time Since the text you are trying to update doesn't have to do with the UISegmentedControl I think you should be able to use a more specific cell identifier and add the control only on cell creation.

You're right, it is creating a new instance of the UISegmentedControl. It's because you are using a generic cell identifier, @"Cell", then adding the UISegmentedControl each time, never removing it. The cells get cached containing the UISegmentedControl, you retrieve the cached cell and add the control again.

You could use a more specific cell identifier and if cell! = nil you know it contains the UISegmentedControl already. Or create a new cell each time that way you're not using a cached cell that already contains the control.

With the image view you just set the cells image view property without adding a new view to the cell so that one is ok, it gets replaced each time. Since the text you are trying to update doesn't have to do with the UISegmentedControl I think you should be able to use a more specific cell identifier and add the control only on cell creation.

Even better, create a custom UITableViewCell subclass and use that. There is no reason to restrict yourself to the default cell types if you have more complex needs. – TechZen Jan 5 '10 at 20:08 Thanks for the answers.

I was just wondering how custom UITableViewCells would assist in this particular circumstance (I'm relatively new to iPhone development). Also, it seems that using custom cells means that the rounded appearance of the cells in a grouped view disappears (replaced by square conrners). – Urizen Jan 6 '10 at 13:53.

(void)viewDidLoad { super viewDidLoad; NSArray *arr1=NSArray arrayWithObjects:@"img1. Jpg",@"img2. Jpg",nil; NSArray *arr2=NSArray arrayWithObjects:@"img1.

Jpg",@"img2. Jpg",@"img3. Jpg",@"img4.

Jpg",@"img5. Jpg",@"img6. Jpg",nil; NSArray *arr3=NSArray arrayWithObjects:@"img6.

Jpg",@"img5. Jpg",@"img2. Jpg",@"img1.

Jpg",nil; Imgs = NSArray alloc initWithArray:NSArray arrayWithObjects:arr1,arr2,arr3,nil; NSDictionary *dic1=NSDictionary dictionaryWithObjectsAndKeys:@"Ahmedabad",@"Name",@"Picture 5. Png",@"Rating",@"Picture 1. Png",@"Photo",arr1,@"img",nil; NSDictionary *dic2=NSDictionary dictionaryWithObjectsAndKeys:@"Rajkot",@"Name",@"Picture 5.

Png",@"Rating",@"Picture 2. Png",@"Photo",nil; NSDictionary *dic3=NSDictionary dictionaryWithObjectsAndKeys:@"Baroda",@"Name",@"Picture 5. Png",@"Rating",@"Picture 7.

Png",@"Photo",nil; tblArray=NSArray alloc initWithObjects:dic1,dic2,dic3,nil; myTbl reloadData; } - (void)viewWillAppear:(BOOL)animated { super viewWillAppear:animated; self. NavigationController. NavigationBarNavigationController.

NavigationBar setUserInteractionEnabled:YES; } - (void)viewWillDisappear:(BOOL)animated { super viewWillDisappear:animated; self. NavigationController. NavigationBar } -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 1; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return tblArray count; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ NSString *CellIdentifer=NSString stringWithFormat:@"%i",indexPath.

Row; UITableViewCell *cell=tableView dequeueReusableCellWithIdentifier:CellIdentifer; if(cell==nil){ cell=self myCustomCell:CellIdentifer dicToSet:tblArray objectAtIndex:indexPath. Row; cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator; } return cell; } -(UITableViewCell*)myCustomCell:(NSString*)CellIdentifer dicToSet:(NSDictionary*)dicToSet{ UITableViewCell *cell=UITableViewCell alloc initWithFrame:CGRectMake(0, 0, 320, 44) reuseIdentifier:CellIdentifer autorelease; UIImageView *imgV=UIImageView alloc initWithFrame:CGRectMake(2, 2, 40, 40); imgV setImage:UIImage imageNamed:dicToSet valueForKey:@"Photo"; cell addSubview:imgV; imgV release; UILabel *lbl=UILabel alloc initWithFrame:CGRectMake(44, 2, 276, 20); lbl setText:dicToSet valueForKey:@"Name"; cell addSubview:lbl; lbl setBackgroundColor:UIColor clearColor; lbl setFont:UIFont fontWithName:@"Helvetica-Bold" size:18; lbl release; UIImageView *imgV1=UIImageView alloc initWithFrame:CGRectMake(44, 24, 70, 20); imgV1 setImage:UIImage imageNamed:dicToSet valueForKey:@"Rating"; cell addSubview:imgV1; imgV1 release; return cell; } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ nxtPlcDtl=plcFullDtl alloc initWithNibName:@"plcFullDtl" bundle:nil; nxtPlcDtl. Dict=NSDictionary alloc initWithDictionary:tblArray objectAtIndex:indexPath.

Row; nxtPlcDtl. Imgs = Imgs objectAtIndex:indexPath. Row; nxtPlcDtl.

Comment1 = comment1 objectAtIndex:indexPath. Row; nxtPlcDtl. Vedio = vedio objectAtIndex:indexPath.

Row; self. NavigationController pushViewController:nxtPlcDtl animated:YES; }.

I'm pretty sure this got posted in the wrong thread. – TechZen Jan 5 '10 at 20:06.

I add two UILabels to a UITableViewCell and then name and number labels to that cell. When I reload the data in the UITableView (whether I add or delete a contact from the table view) the data in the labels are overlapping which means it's not reloading the labels, until the entire view is reloaded. Can anyone please help?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions