I want to disable reloading table view when scrolling. Now, my app when user scroll the uitableview, cellForRowAtIndexPath has been recalled. How can I disable it when srcolling? Please give me some advice. Thanks in advance.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier = [NSString stringWithFormat:#"%d,%d",indexPath.section,indexPath.row];
UITableViewCell *cell = [_tableView dequeueReusableCellWithIdentifier:CellIdentifier];
UILabel *FileNameLabel;
UILabel *UploadTimeLabel;
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
CFileNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 0, 130, 30)];
UploadTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 20, 130, 25)];
FileNameLabel.tag = 1000;
FileNameLabel.backgroundColor = [UIColor clearColor];
FileNameLabel.font = [UIFont fontWithName:#"Helvetica" size:14];
FileNameLabel.font = [UIFont boldSystemFontOfSize:14];
FileNameLabel.textColor = [UIColor blackColor];
// FileNameLabel.text =[temp objectAtIndex:indexPath.row];
[cell.contentView addSubview: FileNameLabel];
[FileNameLabel release];
UploadTimeLabel.tag = 2000;
UploadTimeLabel.backgroundColor = [UIColor clearColor];
UploadTimeLabel.font = [UIFont fontWithName:#"Helvetica" size:12];
UploadTimeLabel.textColor = [UIColor grayColor];
// UploadTimeLabel.text = [UploadTimeArray objectAtIndex:indexPath.row];
[cell.contentView addSubview: UploadTimeLabel];
[UploadTimeLabel release];
}
if( [OriginalArray count] > 0)
{
UILabel *fileNameLbl = (UILabel*)[cell.contentView viewWithTag:1000];
//fileNameLbl.text =[temp objectAtIndex:indexPath.row];
fileNameLbl.text =[[OriginalArray valueForKey:#"FILENAME"] objectAtIndex:indexPath.row];
UILabel *uploadlbl = (UILabel*)[cell.contentView viewWithTag:2000];
uploadlbl.text =[[OriginalArray valueForKey:#"UPLOADTIME"] objectAtIndex:indexPath.row];
}
_tableView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
return cell;
}
You cannot block the cellForRowAtIndexPath: from calling when scrolling the tableview. If something need not happen every time, You may keep it in if condition.
if (cell == nil)
{
//Functionality goes here when it not needed to happen every time.
}
Do not implement the method UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"yourID"]; or UITableViewCell *cell = [tableView dequeueCellWithReuseIdentifier:nil];
It will prevent the table view from reusing the cell. But its not a good idea if your tableview is going to contain large number of cell. Hope this helps. :)
Instead of trying to avoid being reloaded, maybe you could play with your data source, so that it appears as the data doesn't change. I hope you understand what I mean.
use dequecellforrowatindex method to avoid cell reloading.
Related
I want to implement data sheet to display history of user. I want to implement that design like this:
But I dont know how to do that...Can anyone please help me
Edit:
Add the horizontal line at the specific position and the label at the position and it will look like this.
Create a tableview and than in cellForRowAtIndexPath method add this code..
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *SimpleTableIdentifier;
UITableViewCell * cell;
SimpleTableIdentifier = #"SimpleTableIdentifier";
cell = [tableView dequeueReusableCellWithIdentifier: nil];
if(cell == nil) {
cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:SimpleTableIdentifier];
UILabel * numLbl = [[UILabel alloc] initWithFrame:CGRectMake(0,5,33,30)];
numLbl.text = #"1";
[numLbl setFont:[UIFont fontWithName:#"Helvetica" size:10.0]];
numLbl.backgroundColor = [UIColor clearColor];
[cell addSubview:numLbl];
UILabel * nameLbl = [[UILabel alloc] initWithFrame:CGRectMake(30,5,50,30)];
nameLbl.text = #"john%Lakeview";
[nameLbl setFont:[UIFont fontWithName:#"Helvetica" size:10.0]];
nameLbl.backgroundColor = [UIColor clearColor];
[cell addSubview:nameLbl];
//create a hoizontal separator in cell to display it like column
UIView* hSeparatorview1 = [[UIView alloc] initWithFrame:CGRectMake(25, 0, 1, 30)];
hSeparatorview1.backgroundColor = [UIColor blackColor];
hSeparatorview1.tag = 1;
[cell addSubview:hSeparatorview1];
UIView* hSeparatorview2 = [[UIView alloc] initWithFrame:CGRectMake(85, 0, 1, 30)];
hSeparatorview2.backgroundColor = [UIColor blackColor];
hSeparatorview2.tag = 2;
[cell addSubview:hSeparatorview2];
}
return cell;
}
//this method is used to set the hight of the tableview cell
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
{
return 30;
}
I have created it for only two label and two horizontal view but you can create as many as you like.
And yes dot forget to place this code in didSelectRowAtIndexPath otherwise horizontal view will disappear when user click the cell.
- (void)tableView:(UITableView *)atableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//get the cell which is selected
UITableViewCell *selectedCell = [atableView cellForRowAtIndexPath:indexPath];
//set cell horizontal saparator view color of selected cell bcoz when cell selected all view color is gone
UIView *hSeparatorview1=[selectedCell viewWithTag:1];
hSeparatorview1.backgroundColor = [UIColor blackColor];
UIView *hSeparatorview2=[selectedCell viewWithTag:2];
hSeparatorview2.backgroundColor = [UIColor blackColor];
}
Better to try with Custom tableview Cell for text,and UIViews for lines.I'm also done the same in my app.
since a couple of days i'm trying to print two strings coming from an array of data, parsed from a xml file coming from my server (that was long :D). The problem is that i only managed to print one of the two strings. i made my researches and find a pointer on a technic but i can't managed to make that technic work if someone could help me please. here is my code :
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = #"MyIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
}
for(UIView *eachView in [cell subviews]){
[eachView removeFromSuperview];
}
UILabel *lbl1 = [[UILabel alloc]initWithFrame:CGRectZero];
[lbl1 setFont:[UIFont fontWithName:#"Helvetica" size:12.0]];
[lbl1 setTextColor:[UIColor grayColor]];
int storyIndex = [indexPath indexAtPosition: [indexPath length] - 1];
lbl1.text = [[stories objectAtIndex: storyIndex] objectForKey: #"creation_date"];
NSLog(lbl1.text);
[cell addSubview:lbl1];
[lbl1 release];
UILabel *lbl2 = [[UILabel alloc]initWithFrame:CGRectZero];
[lbl2 setFont:[UIFont fontWithName:#"Helvetica" size:12.0]];
[lbl2 setTextColor:[UIColor blackColor]];
lbl2.text = [[stories objectAtIndex: storyIndex] objectForKey: #"name"];
NSLog(lbl2.text);
[cell addSubview:lbl2];
[lbl2 release];
//Used to do this ---> int storyIndex = [indexPath indexAtPosition: [indexPath length] - 1];
//[cell.textLabel setText:[[stories objectAtIndex: storyIndex] objectForKey: #"creation_date"]];
return cell;
}
Problem I see is that you are adding subview directly to cell. You should add it to cell.contentview like this:
- (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] autorelease];
CGRect frame = CGRectMake(0, 0, 160, 50);
UILabel *label = [[UILabel alloc] initWithFrame:frame];
label.textAlignment = UITextAlignmentRight;
[cell.contentView addSubview:label];
[label release];
}
// Get a reference to the label here
label.text = #"9:00am";
return cell;
}
Also I strongly suggest to create subclass for UITableViewCell.
Rather than trying to dynamically create labels for a cell in this way you are better off just using a custom table view cell that already has the two labels positioned as you want. You can then set the text for those labels directly.
Looking at your code, I also recommend that you move to ARC rather than MRC and also read up on the documentation for table views; you don't need to check for a nil value returned from the reuse queue in this case, or if you are using correctly configured custom cells on a storyboard.
So I am having trouble showing my data in a UITableView. I do believe it has something to do with reusing the cells. I have checked online and here at SO but have not found a solution that works for me. Any help would be appreciated.
I have an Array that is populated by text and pictures. I am then showing the information in a tableView. If I were to use static sized cells everything works out fine, but the amount of text changes, so I have also implemented the heightForRowAtIndexPath method. This works as well, until I scroll all the way down to the bottom.
After that, when I scroll back up, all the cell heights change and the display gets all jumbled. Some text gets cut off, pictures get chopped and some of the cells only have the last portion of text. I really think it has something to do with reusing the cells, but I don’t know how to attack this problem. Below is my code for cellForRowAtIndexPath and heightForRowAtIndexPath.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
if ([[_theBigArray objectAtIndex:indexPath.row] isKindOfClass:[NSString class]])
{
NSString *label = [_theBigArray objectAtIndex:indexPath.row];
CGSize stringSize = [label sizeWithFont:[UIFont systemFontOfSize:15] constrainedToSize:CGSizeMake(320, 9999) lineBreakMode:NSLineBreakByWordWrapping];
UITextView *textV = [[UITextView alloc] initWithFrame:CGRectMake(5, 5, 290, stringSize.height +50)];
textV.font = [UIFont systemFontOfSize:15];
textV.text = [_theBigArray objectAtIndex:indexPath.row];
textV.textColor = [UIColor blackColor];
textV.editable = NO;
[cell.contentView addSubview:textV];
}
else if ([[_theBigArray objectAtIndex:indexPath.row] isKindOfClass:[UIImage class]])
{
UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(5, 5, 290, 100)];
imageV.contentMode = UIViewContentModeScaleAspectFit;
imageV.image = [_theBigArray objectAtIndex:indexPath.row];
[cell.contentView addSubview:imageV];
}
return cell;
[tableView reloadData];
}
For heightForRowAtIndexPath
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
int rowHeight = 0.0f;
if ([[_theBigArray objectAtIndex:indexPath.row] isKindOfClass:[NSString class]])
{
NSString *temp = [_theBigArray objectAtIndex:indexPath.row];
CGSize size = [temp sizeWithFont:[UIFont systemFontOfSize:14.0f] constrainedToSize:CGSizeMake(320, 9999) lineBreakMode:NSLineBreakByWordWrapping];
rowHeight = size.height+50;
}
else if ([[_theBigArray objectAtIndex:indexPath.row] isKindOfClass:[UIImage class]])
{
rowHeight = 115.0f;
}
//NSLog(#"rowHeight is %i", rowHeight);
return rowHeight;
[tableView reloadData];
}
I even tried to make two different cells and call them separately, but the same thing happens. I did still use the same heightForRowAtIndexPath method.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *newCell = [[UITableViewCell alloc] init];
if ([[_theBigArray objectAtIndex:indexPath.row] isKindOfClass:[NSString class]])
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"Cell"];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:#"Cell"];
}
NSString *label = [_theBigArray objectAtIndex:indexPath.row];
CGSize stringSize = [label sizeWithFont:[UIFont systemFontOfSize:15] constrainedToSize:CGSizeMake(320, 9999) lineBreakMode:NSLineBreakByWordWrapping];
UITextView *textV = [[UITextView alloc] initWithFrame:CGRectMake(5, 5, 290, stringSize.height +50)];
textV.font = [UIFont systemFontOfSize:15];
textV.text = [_theBigArray objectAtIndex:indexPath.row];
textV.textColor = [UIColor blackColor];
textV.editable = NO;
[cell.contentView addSubview:textV];
newCell = cell;
}
else if ([[_theBigArray objectAtIndex:indexPath.row] isKindOfClass:[UIImage class]])
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"PictureCell"];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:#"PictureCell"];
}
UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(5, 5, 290, 100)];
imageV.contentMode = UIViewContentModeScaleAspectFit;
imageV.image = [_theBigArray objectAtIndex:indexPath.row];
[cell.contentView addSubview:imageV];
newCell = cell;
}
return newCell;
[tableView reloadData];
}
Any ideas?
The main problem is that you're adding subviews to cells every time they scroll in, but when a cell is reused, it will already have those subviews added. (That is, when a cell is reused, it will already have a UITextView or UIImageView depending on the reuse identifier.)
You need to check if these subviews exist first; this is commonly done by using the -[UIView viewWithTag] method, or by subclassing UITableViewCell and assigning each view as a property.
(You can take a look at the SO question How to get other control value from UITableViewCell? to see how to use viewWithTag. I would avoid subclassing UITableViewCell until you're more comfortable with the out-of-the-box implementation.)
Also, this line of code:
UITableViewCell *newCell = [[UITableViewCell alloc] init];
is a terrible idea, because you are creating a new UITableViewCell without checking to see if you can reuse one first. This defeats the entire purpose of reusing cells, which is fast scrolling performance. Instead, just declare it without initializing it:
UITableViewCell *newCell;
Also, in heightForRowAtIndexPath, you are
declaring rowHeight as an int (it should be a CGFloat)
trying to call reloadData after the method returns (which will never happen, but you should never try to call reloadData from this method)
I am creating grouped table in my application.
It works fine. But when I scroll the table upward and backward reprinted text on previous cell. It look like horrible.
This is my Code
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"cellID"];
if (!cell)
{
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:#"cellID"] autorelease];
}
/*
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
*/
if(indexPath.section == 0)
{
cell.backgroundColor = [UIColor clearColor];
cell.accessoryType = UITableViewCellAccessoryNone;
float rowHeight = [DetailViewController calculateHeightOfTextFromWidth:[dict objectForKey:#"golf_name"] :[UIFont boldSystemFontOfSize:18] :290 :UILineBreakModeTailTruncation];
UILabel *categorName = [[UILabel alloc] initWithFrame:CGRectMake(20, 5, 290, rowHeight)];
categorName.font = [UIFont boldSystemFontOfSize:20];
categorName.numberOfLines = 5;
categorName.backgroundColor = [UIColor clearColor];
categorName.textColor = [UIColor whiteColor];
categorName.text = [dict objectForKey:#"golf_name"];
[cell addSubview:categorName];
[categorName release];
}
if(indexPath.section == 1)
{
cell.backgroundColor = [UIColor whiteColor];
cell.accessoryType = UITableViewCellAccessoryNone;
UILabel *categorName = [[UILabel alloc] initWithFrame:CGRectMake(50, 10, 70, 20)];
categorName.font = [UIFont boldSystemFontOfSize:15];
categorName.numberOfLines = 5;
categorName.backgroundColor = [UIColor clearColor];
categorName.textColor = [UIColor colorWithRed:145.0f/255.0f green:162.0f/255.0f blue:184.0f/255.0f alpha:1];
categorName.text = #"Phone";
[cell addSubview:categorName];
[categorName release];
UILabel *phone = [[UILabel alloc] initWithFrame:CGRectMake(110, 10, 290, 20)];
phone.font = [UIFont boldSystemFontOfSize:15];
phone.numberOfLines = 5;
phone.backgroundColor = [UIColor clearColor];
//categorName.textColor = [UIColor colorWithRed:145.0f/255.0f green:162.0f/255.0f blue:184.0f/255.0f alpha:1];
phone.text = [dict objectForKey:#"golf_phone"];
[cell addSubview:phone];
[phone release];
}
if(indexPath.section == 2)
{
cell.backgroundColor = [UIColor whiteColor];
cell.accessoryType = UITableViewCellAccessoryNone;
UILabel *categorName = [[UILabel alloc] initWithFrame:CGRectMake(20, 10, 90, 20)];
categorName.font = [UIFont boldSystemFontOfSize:15];
categorName.numberOfLines = 5;
categorName.backgroundColor = [UIColor clearColor];
categorName.textColor = [UIColor colorWithRed:145.0f/255.0f green:162.0f/255.0f blue:184.0f/255.0f alpha:1];
categorName.text = #"Home page";
[cell addSubview:categorName];
[categorName release];
UILabel *phone = [[UILabel alloc] initWithFrame:CGRectMake(110, 10, 230, 20)];
phone.font = [UIFont boldSystemFontOfSize:15];
phone.numberOfLines = 5;
phone.backgroundColor = [UIColor clearColor];
//categorName.textColor = [UIColor colorWithRed:145.0f/255.0f green:162.0f/255.0f blue:184.0f/255.0f alpha:1];
phone.text = [dict objectForKey:#"golf_url"];
[cell addSubview:phone];
[phone release];
}
.......
.....
return cell;
}
Update
My original answer was not the correct way to reuse UITableViewCell's. You should never use "CellID%d%d"(indexPath.row & indexPath.column) as cell identifier, that defeats the very purpose of cell reuse. It will create separate UITableViewCell for every row in the table, and every one of those cells stays in memory. Imagine what will happen if you have a tableView with around 1000 rows.
The real answer to OP's question is - make sure to reset a UITableViewCell returned by dequeueReusableCellWithIdentifier because it might return a cell that is already used and its UI populated. For example, if you didn't reset the texts in UILabel, it might contain strings that should have been shown in a different row of your tableView.
My original Answer (Don't use this)
Hiren, just try,
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[NSString stringWithFormat:#"CellID%d%d",indexPath.section,indexPath.row]];
if (!cell){
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:[NSString stringWithFormat:#"CellID%d%d",indexPath.section,indexPath.row]] autorelease];
}
instead of
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"cellID"];
if (!cell)
{
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:#"cellID"] autorelease];
}
Please read this..you will understand how to give cell identifiers..
When you create the UITableView object, Set the rowHeight for each cell.
myTableView.rowHeight = 50; //Depend on your requirement,
Let me know if you still struggle to get the desire result.
If your cell's height is not constant then implement heightForRowAtIndexPath method,
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
And return different-2 height for each cell.
try adding any color because clearcolor is making label transparent.
I'm really new to Xcode and Objective C but I can't seem to find a tutorial on a simple table I'd like to create. I'd like to have a table (grouped style) with only three rows but two columns. Column A would have a label (like 'Name:') and column B would have the actual data ("Jason").
I can't seem to find how to do this. Unless I'm just completely looking up the wrong thing? Was hoping someone could help me on how to do this or point me in the right direction.
Thank you!!
You don't want to use a table with 2 columns. They are not used in iOS.
You should use a UITableViewCell with a UITableViewCellStyleValue2 style. And you want to set #"Name" as textLabel.text and #"Jason" as detailTextLabel.text.
You have to change the tableView:cellForRowAtIndexPath: a little bit.
// 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 = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text = #"Name";
cell.detailTextLabel.text = #"Jason";
return cell;
}
You can't "really" create columns in UITableView, but you can use Cell Styles to achieve a similar effect.
You can use the UITableViewCellStyleValue1 style to achieve what you say
Here is an exemple:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
cell.textLabel.text = #"Name";
cell.detailTextLabel.text = #"Jason";
return cell;
}
Here is an exemple of what it looks like:
http://blog.blackwhale.at/wp-content/uploads/2009/06/Bild-3.png
Or, but more complicated if you are new to ObjectiveC, you can create your own CellView in a XIB and use it in your code:
http://www.bdunagan.com/2009/06/28/custom-uitableviewcell-from-a-xib-in-interface-builder/
Edit: Sorry, fluchtpunkt has been faster than me ;)
maybe you should add a label on the table cell, and give a border
like this :
//------------------- first column -------------------------------------------------------------------
UILabel * label1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 312, 43)];
[label1 setFont:[UIFont fontWithName:#"arial" size:18]];
[label1 setTextColor:[UIColor blackColor]];
label1.backgroundColor = [UIColor clearColor];
label1.layer.borderColor=[[UIColor lightGrayColor]CGColor];
label1.layer.borderWidth= 1.0f;
label1.numberOfLines = 0;
label1.text = [NSString stringWithFormat:#" %#",[[yourArray objectAtIndex:indexPath.row]objectForKey:#"xxxxx"]];
[cell.contentView addSubview:label1];
//------------------- second column -------------------------------------------------------------------
UILabel * label2 = [[UILabel alloc]initWithFrame:CGRectMake(314, 0, 125, 43)];
[label2 setFont:[UIFont fontWithName:#"arial" size:18]];
[label2 setTextColor:[UIColor blackColor]];
label2.textAlignment = NSTextAlignmentCenter;
label2.backgroundColor = [UIColor clearColor];
label2.layer.borderColor=[[UIColor lightGrayColor]CGColor];
label2.layer.borderWidth= 1.0f;
label2.text = [NSString stringWithFormat:#"%#",[[yourArray objectAtIndex:indexPath.row]objectForKey:#"xxxxxx"]];
[cell.contentView addSubview:label2];