Custom Check mark for selected Row - ios

I am using a Custom image for checkmark - 'iphone-checkMark#2x.png' in a `UITableViewCell, but it's displaying everywhere in the cell. Can anyone suggest how to make it display only for the single selected cell?
Here is my code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10,10, 300, 30)];
[cell.contentView addSubview:label];
label.text = [tableArr objectAtIndex:indexPath.row];
label.font = [UIFont fontWithName:#"Whitney-Light" size:20.0];
label.tag = 1;
UIImageView *checkmark = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"iphone-checkMark#2x.png"]];
cell.accessoryView = checkmark;
return cell;
}

Less code is better:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
}
cell.textLabel.text = [tableArr objectAtIndex:indexPath.row];
cell.textLabel = [UIFont fontWithName:#"Whitney-Light" size:20.0];
return cell;
}
UPDATE:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
lastIndexPath = indexPath;
[tableView reloadData];
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
if ([lastIndexPath isEqual:indexPath]) {
cell.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"iphone-checkMark.png"]];
} else {
cell.accessoryView = nil;
}
}
UPDATE 2:
Write
//dont forget check for nil
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setValue:lastIndexPath forKey:#"lastIndexPath"];
[defaults synchronize];
Read
NSIndexPath *lastPath = [defaults valueForKey:#"lastIndexPath"];

One way to achieve what you are trying to do is to use a button and set the background image as your checkbox. This button will be your accessoryView. Monitor the touch event on the button and display the boolean accordingly. The sample project in the following link will provide all the code you need to implement this. https://developer.apple.com/library/ios/#samplecode/Accessory/Introduction/Intro.html

Related

UITableViewCellSelectionStyleBlue is not working

I need to use UITableViewCellSelectionStyleBlue for the cell selection style. But whatever style I set it only displays UITableViewCellSelectionStylegray. I am using Xcode 5.
This is my code:
-(UITableViewCell*) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellid = #"Table1";
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellid];
if (cell==Nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid];
}
cell.textLabel.text = [tabledata objectAtIndex:indexPath.row];
cell.selectionStyle =UITableViewCellSelectionStyleBlue;
cell.imageView.image =[UIImage imageNamed:#"cellbgimg.png"] ;
return cell;
}
i am able to change the UITableviewSelectionStyleBlue. Please try below code:
// take a view for the cell...
UIView *cellBg = [[UIView alloc] init];
cellBg.backgroundColor = [UIColor colorWithRed:(76.0/255.0) green:(161.0/255.0) blue:(255.0/255.0) alpha:1.0]; // this RGB value for blue color
cellBg.layer.masksToBounds = YES;
Cell.selectedBackgroundView = cellBg;
Try this one ....
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:#"myCell"];
if (cell == nil)
{
cell = [self tableviewCellWithReuseIdentifier:#"myCell" ForIndexpath:indexPath];
}
[self configureCell:cell forIndexPath:indexPath];
cell.accessoryType = UITableViewCellAccessoryNone;
[cell setSelectionStyle:UITableViewCellSelectionStyleBlue]; // This one for your cell selection style.
return cell;
}

How to add images in UITableViewCells programmatically in iOS

I need to add different images in UITableViewCells programmatically. How can I do that. I am trying some code. But the images are not displayed in UITableViewCells.
This is my code below.
-(void)viewDidLoad
{
arrImages=[[NSMutableArray alloc]initWithObjects:#"image.png",#"image2.png",#"image3.png",#"image4.png",#"image5.png",#"image6.png",#"image7.png",#"image8.png" nil];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *identifier=#"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:#"identifier"];
}
imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 48, 48)];
cell.imageView.image = [UIImage imageNamed:[arrImages objectAtIndex:indexPath.row]];
return cell;
}
This is what you probably want:
- (void)viewDidLoad
{
self.arrImages = [[NSMutableArray alloc] initWithObjects:#"image.png",#"image2.png",#"image3.png",#"image4.png",#"image5.png",#"image6.png",#"image7.png",#"image8.png" nil];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString* CellIdentifier = #"Cell";
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]
}
cell.imageView.image = [UIImage imageNamed:[self.arrImages objectAtIndex:indexPath.row]];
return cell;
}
P.S.: Next time, please make some effort on formatting the source code, explaining what is wrong, what have you tried, what would you like to accomplish. Thanks
Create a property of NSArray in your .h file
#property NSArray *imgArray;
synthesize in your .m file
#synthesize imgArray;
write this in your viewDidLoad
- (void)viewDidLoad
{
[super viewDidLoad];
// Initialize images...
imgArray = [NSArray arrayWithObjects:#"yourFirstImageName.png", #"yourSecondImageName.png", #"yourThirdImageName.png",....., #"yourSeventhImageName.png", nil];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = #"SimpleTableItem";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 48, 48)]; // your cell's height should be greater than 48 for this.
imgView.tag = 1;
[cell.contentView addSubview:imgView];
imgView = nil;
UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(x, y, width, height)];
lbl.backgroundColor = [UIColor clearColor];
[lbl setTag:2];
[cell.contentView addSubview:lbl];
lblDisch = nil;
}
UIImageView *_imgView = (UIImageView *)[cell.contentView viewWithTag:1];
_imgView.image = [UIImage imageNamed:[imgArray objectAtIndex:indexPath.row]];
UILabel *_lbl = (UILabel *)[cell.contentView viewWithTag:2];
_lbl.text = [arrFont objectAtIndex:indexPath.row]; // arrFont is your array
return cell;
}
Hope this will help you.
Create a #property of NSMutableArray in your .h file.
NSMutableArray *data;
Write This Code your .m file.
- (void)viewDidLoad
{
data = [[NSMutableArray alloc]initWithObjects:#"1.jpg",#"2.jpg",#"3.jpg",#"4.jpg",#"5.jpg",#"6.jpg",#"7.jpg",#"8.jpg",#"9.jpg",#"10.jpg",#"11.jpg",#"12.jpg",#"13.jpg",nil];
[super viewDidLoad];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [data count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = #"cellID";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
cell.imageView.image = [UIImage imageNamed:[data objectAtIndex:indexPath.row]];
return cell;
}

Eliminate Duplication of Table View Elements Upon Scroll

Hi I realize that this question has been asked before. I tried the previous solutions however to no avail unfortunately. What I am trying to do is to get my UISwitch to appear and not duplicate itself when scrolling on the table view. This is my current attempt however the UISwitch is not being displayed at all. Any help as to what I am doing wrong would be greatly appreciated!
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = #"RestaurantCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
Restaurant *restaurant = [restaurants objectAtIndex:indexPath.row];
UISwitch *notificationSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(245, 15, 79, 27)];
[notificationSwitch addTarget:self action:#selector(switchChanged:) forControlEvents:UIControlEventValueChanged];
[cell.contentView addSubview:notificationSwitch];
cell.textLabel.text = restaurant.name;
cell.detailTextLabel.text = restaurant.hours;
return cell;
}
Try this:
UISwitch init Method what say
- (id)initWithFrame:(CGRect)frame
Parameters
frame
A rectangle defining the frame of the UISwitch object. The size components of this rectangle are ignored.
Discussion
UISwitch overrides initWithFrame: and enforces a size appropriate for the control
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = #"RestaurantCell";
UISwitch *notificationSwitch = nil;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
notificationSwitch = [[UISwitch alloc] initWithFrame:CGRectZero];
[notificationSwitch addTarget:self action:#selector(switchChanged:) forControlEvents:UIControlEventValueChanged];
notificationSwitch.tag = 101;
cell.accessoryView = switchView;
}
if(!notificationSwitch) {
notificationSwitch = (UISwitch*)[cell.accessoryView viewWithTag:101];
}
Restaurant *restaurant = [restaurants objectAtIndex:indexPath.row];
switch (indexPath.section) {
case 0:
cell.textLabel.text = restaurant.name;
cell.detailTextLabel.text = restaurant.hours;
break;
default:
cell.textLabel.text = #"oh no!";
}
return cell;
}

Accessory type for Cross Sign in iOS

I have a table view and 2 custom cells inside it. I want to use a (X) symbol i.e. the cross symbol and the tick symbol. I know for tick we have UITableViewCellAccessoryCheckmark but what to do for the (X) symbol. Can we have any custom accessory for this or else how to achieve this?
My code:
#pragma mark - Table View Methods
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 2;
}
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
optionsLabelArray = [[NSArray alloc] initWithObjects:#"Yes", #"No", nil];
static NSString *CellIdentifier = #"CheckerCell";
CustomCell *cell =[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.optionLabel.text = [optionsLabelArray objectAtIndex:indexPath.row];
cell.optionLabelSubtitle.text = [optionsLabelSubtitleArray objectAtIndex:indexPath.row];
if(indexPath.row == 0)
{
cell.textLabel.textColor = [UIColor colorWithRed:78/255.0 green:157/255.0 blue:19/255.0 alpha:1.0];
}
else if(indexPath.row == 1)
{
cell.textLabel.textColor = [UIColor colorWithRed:167/255.0 green:19/255.0 blue:43/255.0 alpha:1.0];
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (tableView ==_optionsTableView1) {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
previousSelectedCell1.accessoryType = UITableViewCellAccessoryNone;
cell.accessoryType=UITableViewCellAccessoryCheckmark;
previousSelectedCell1 = cell;
NSLog(#"Row : %ld", (long)indexPath.row);
if(indexPath.row == 0)
{
self.weatherSafeToPlay = YES;
}
else
{
// MatchDayDataController *sharedController = [MatchDayDataController sharedDataController];
// sharedController.actions = [sharedController.actions stringByAppendingString:#"Check Weather. "];
//[sharedController.actions appendString:#"Check Weather. "];
self.weatherSafeToPlay = NO;
}
NSLog(#"Is Weather safe: %hhd", self.weatherSafeToPlay);
}
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
not heard of any accessory type for cross but in such cases, i simply use unicode characters.
It's lighter than using an image and is a simple matter of just changing the text.
#"\u2713" for ✓
#"\u2717" for ✗
You can:
Create a custom UITableViewCell having a 32by32 (or any dimension) UILabel (on the right/left/middle/wherever)
in -didSelectRowAtIndexPath, you can change the text of this UILabel
#"\u2713" for checkmark or #"\u2717" for crossmark
A simple example (on the default UITableViewCell's default textLabel, just for the idea):
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if([cell.textLabel.text isEqualToString:#"\u2713"]) {
cell.textLabel.text = #"\u2717";
}
else {
cell.textLabel.text = #"\u2713";
}
}
OR... when not using a custom cell, something like:
-(UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
}
//set your text to cell.textLabel.text
//create your own UILabel
UILabel *lblAcc = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 32, 32)];
[lblAcc setTag:100];
[lblAcc setText:#"?"];
[lblAcc setBackgroundColor:[UIColor redColor]];
[lblAcc setTextAlignment:NSTextAlignmentCenter];
//set as custom AccessoryView on cell
[cell setAccessoryView:lblAcc];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSString *strAccessory = [(UILabel *) [cell viewWithTag:100] text];
//the -isEqualToString is a bit heavier than checking a simple bool or int value
//so since you should be remembering the selected cells anyways, you can change
//the if-logic to compare with a bool rather than the string comparison.
//but for now, we'll do:
if([strAccessory isEqualToString:#"\u2713"]) {
[(UILabel *) [cell viewWithTag:100] setText:#"\u2717"];
}
else {
[(UILabel *) [cell viewWithTag:100] setText:#"\u2713"];
}
}
for more unicode characters... this link:
http://en.wikibooks.org/wiki/Unicode/List_of_useful_symbols
You can assign your own image to accessoryView of table cell. Create an image of (X) symbol and use that image as accessoryView.
cell.accessoryView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:#"Your X Image"]];

Data repeat in UITableView when scrolling

I use bellow codes to show data on TableView but when scrolling, data repeat and other data lost.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [FileCompletedArray count];
}
cellForRowatindexpath ():
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"CellIdentifier";
UITableViewCell *cell = [_tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
UILabel *FileNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 100, 30)];
FileNameLabel.backgroundColor = [UIColor clearColor];
FileNameLabel.font = [UIFont fontWithName:#"Helvetica" size:16];
FileNameLabel.font = [UIFont boldSystemFontOfSize:16];
FileNameLabel.textColor = [UIColor blackColor];
NSLog(#"Reseversed TEMP array %#",FileCompletedArray);
FileNameLabel.text =[FileCompletedArray objectAtIndex:indexPath.row];
[cell.contentView addSubview: FileNameLabel];
[FileNameLabel release];
}
return cell;
}
Do you have any solutions? Thanks in advance
use cell Identifier different
For example like bellow...
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier = [NSString stringWithFormat:#"%d,%d",indexPath.section,indexPath.row];
UITableViewCell *cell = [_tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
/// write your code here..
}
}
OR set nil like bellow..
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//static NSString *CellIdentifier = #"CellIdentifier";
UITableViewCell *cell = [_tableView dequeueReusableCellWithIdentifier:nil];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil] autorelease];
/// write your code here..
}
}
This problem is generated because Your UITableView Reuse Cell instant of create new one.
I give you some suggestion that may be helpful for you.
1) add Controller in between
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
/// Your code of initialization of controller;
}
/// set property of controllers such like (Text UILabel, image of UIImageView...etc) .
return cell;
}
1) Add Your Controller to cell.contentView.
EDITED:
Before You follow my Edited Answer i want to tell you that following code is bad for memory management because it will create new cell for each rows of UITableView, so be careful for it.
But it is better for if UITableView Have Limited row about (50-100 may be ) os use following code if is it suitable for you.
NSString *CellIdentifier = [NSString stringWithFormat:#"S%1dR%1d",indexPath.section,indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil)
{
/// Your whole code of controllers;
}
You are setting the text of the label only when creating a new cell. However, during cell reuse, new cell is not created. Hence your code for setting/changing text is not working. You can use this modified code.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"CellIdentifier";
UITableViewCell *cell = [_tableView dequeueReusableCellWithIdentifier:CellIdentifier];
UILabel *FileNameLabel=nil;
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
FileNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 100, 30)];
FileNameLabel.tag = 1001;
FileNameLabel.backgroundColor = [UIColor clearColor];
FileNameLabel.font = [UIFont fontWithName:#"Helvetica" size:16];
FileNameLabel.font = [UIFont boldSystemFontOfSize:16];
FileNameLabel.textColor = [UIColor blackColor];
[cell.contentView addSubview: FileNameLabel];
[FileNameLabel release];
}
if(!FileNameLabel)
FileNameLabel = [cell.contentView viewWithTag:1001];
FileNameLabel.text =[FileCompletedArray objectAtIndex:indexPath.row];
return cell;
}
Alternatively you can use the default textLabel instead of creating and adding new label
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"CellIdentifier";
UITableViewCell *cell = [_tableView dequeueReusableCellWithIdentifier:CellIdentifier];
UILabel *FileNameLabel=nil;
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.textLabel.font = [UIFont fontWithName:#"Helvetica" size:16];
cell.textLabel.font = [UIFont boldSystemFontOfSize:16];
cell.textLabel.textColor = [UIColor blackColor];
}
cell.textLabel.text =[FileCompletedArray objectAtIndex:indexPath.row];
return cell;
}
I also faced same problem, the problem occurs when we reuse the cells. At the time of reusing the data is already present in it and we write some more data also, to sort out this, i did a minor change to my table view delegate method cellForRowAtIndexPath. Here the code which i use always using table view.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"cell"];
if (!cell) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:#"cell"];
}
for (UIView *view in cell.contentView.subviews) {
[view removeFromSuperview];
}
return cell;
}
The for loop gets executed when we are reusing some cell and what it does is removing all the previous data present in UITableViewCell
Hope this will help someone.

Resources