Guys can someone 'tell me why I can not align well the label in these cell? ... The space between the black and the yellow label should be the same but I can not figure out the exact point you want to change in the code ... Surely it is a trivial but I'm lost
This is the code I'm using
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
{
NSString *comment = [[self.objects objectAtIndex:[indexPath row]] objectForKey:#"TITOLO"];
CGFloat whidt = 220;
UIFont *FONT = [UIFont systemFontOfSize:13];
NSAttributedString *attributedText =[[NSAttributedString alloc] initWithString:comment attributes:# { NSFontAttributeName: FONT }];
CGRect rect = [attributedText boundingRectWithSize:(CGSize){whidt, MAXFLOAT}
options:NSStringDrawingUsesLineFragmentOrigin
context:nil];
CGSize size = rect.size;
return size.height +50;
}
- (FFCustomListaEsamiCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object {
FFCustomListaEsamiCell *cell = (FFCustomListaEsamiCell * )[self.tableView dequeueReusableCellWithIdentifier:#"Cell"];
if (!cell) {
cell = [[FFCustomListaEsamiCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:#"Cell"];
}
NSString *text = [object objectForKey:#"TITOLO"];
CGSize constraint = CGSizeMake(220 , 20000.0f);
UIFont *FONT = [UIFont systemFontOfSize:13];
CGSize size = [text boundingRectWithSize:constraint options:NSStringDrawingUsesLineFragmentOrigin attributes:#{NSFontAttributeName:FONT }context:nil].size;
cell.FFTitoloEsameLabel.frame = CGRectMake(17,10, 240, MAX(size.height, 10.0)+10.0 );
cell.FFTitoloEsameLabel.text = text;
NSDateFormatter *FFDataFormattata = [[NSDateFormatter alloc] init];
[FFDataFormattata setDateFormat:FF_DATE_FORMATTER];
cell.FFDataEsameLabel.text = [NSString stringWithFormat: #"%#",[FFDataFormattata stringFromDate:[object objectForKey:FF_ESAMI_DATA_STRING]]];
PFObject *rowObject = [self.objects objectAtIndex:indexPath.row];
if([[rowObject objectForKey:FF_ESAMI_STATUS] boolValue]) {
cell.last.image = [UIImage imageNamed:#"FFIMG_ClockTAG"];
}
else
{
}
return cell;
}
I solved it by removing the auto-layout and setting the blocks with the size inspector ... I think it's the best solution and that is not a problem especially ... I hope ...
Related
i have created a custom cell with a textview. I need to expand the height of the textview and the height of the custom cell according to the content in the textview without using auto layout. can any one help me
This is the code:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 80;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return sendername.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier1 = #"MenuCtrl";
tsecureMsgConCell *cell = [tabVieConv dequeueReusableCellWithIdentifier:CellIdentifier1];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:#"MsgConCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
cell.userName.text = [sendername objectAtIndex:indexPath.row];
cell.msgContentTxView.text = [msgContents objectAtIndex:indexPath.row];
NSString * sentDateCell = [msgSenddate objectAtIndex:indexPath.row];
NSString * replyDateCell = [msgRevidate objectAtIndex:indexPath.row];
thredIdCell = [TSecureMsgId objectAtIndex:indexPath.row];
if ([sentDateCell isEqualToString:#"NULL"])
{
cell.dateLbl.text = [msgRevidate objectAtIndex:indexPath.row];
cell.timeLbl.text = [msgRecTime objectAtIndex:indexPath.row];
cell.imgVew.image = [UIImage imageNamed:#"recive.png"];
}
else if ([replyDateCell isEqualToString:#"NULL"])
{
cell.dateLbl.text = [msgSenddate objectAtIndex:indexPath.row];
cell.timeLbl.text = [msgSendTime objectAtIndex:indexPath.row];
cell.imgVew.image = [UIImage imageNamed:#"sent.png"];
}
return cell;
}
msgContentTxView - is my textview
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSUInteger row = indexPath.row;
if (row != NSNotFound)
{
if ([exapmlestring length] > 0)
{
CGFloat padding = 17.0f;
CGFloat labelWidth = self.tableview.bounds.size.width - padding*2;
NSDictionary *attributesDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
[UIFont fontWithName:#"HelveticaNeue" size:17.0], NSFontAttributeName,
nil];
NSAttributedString *text = [[NSAttributedString alloc] initWithString:exapmlestring attributes:attributesDictionary];
NSStringDrawingOptions options = NSStringDrawingUsesLineFragmentOrigin;
///size
CGRect boundingRect = [text boundingRectWithSize:CGSizeMake(labelWidth, CGFLOAT_MAX)
options:options
context:nil];
boundingRect.size.height = boundingRect.size.height + 100;
return (CGFloat) (ceil(boundingRect.size.height) + padding*2);
}
}
return 0;
}
I am tring to calculate the height of text labels in uitableview cells. After seeing that sizewithfont was deprecated with ios 7, I implemented sizewithattributes but the return values were way smaller than what it should be for the label to be of correct size for the text it contains. I also tried the sizetofit method also to no avail.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
NSDictionary *message = self.messages[indexPath.row];
UILabel *nameLabel = (UILabel *)[cell.contentView viewWithTag:1];
UILabel *messageContent = (UILabel *)[cell.contentView viewWithTag:3];
UIImageView *image = (UIImageView *)[cell.contentView viewWithTag:2];
messageContent.text = [message objectForKey:#"messageContent"];
NSString *content = [message objectForKey:#"messageContent"];
NSLog(#"Message: %#", content);
CGSize textSize = [content sizeWithAttributes:#{ NSFontAttributeName : [UIFont fontWithName:#"HelveticaNeue-Light" size:17.0]}];
messageContent.font = [UIFont fontWithName:#"HelveticaNue-Light" size:17.0];
CGRect messageFrame = messageContent.frame;
messageFrame.size = textSize;
messageContent.frame = messageFrame;
nameLabel.text = [message objectForKey:#"senderName"];
NSString *senderPicture = [message objectForKey:#"senderPicture"];
UIImage* myImage = [UIImage imageWithData:
[NSData dataWithContentsOfURL:
[NSURL URLWithString: senderPicture]]];
image.image = myImage;
image.layer.cornerRadius = 27.0;
image.layer.masksToBounds = YES;
//Configure the cell...
return cell;
}
Attribution:
user/Elio.d has a great answer here.
I've attached a transcript of his answer below. If it helps you please be sure to go send Elio.d an upvote on his original answer
Transcript:
well you can try this :
NSDictionary *attributes = #{NSFontAttributeName: [UIFont fontWithName:#"HelveticaNeue" size:14.0f]};
// NSString class method: boundingRectWithSize:options:attributes:context is
// available only on ios7.0 sdk.
CGRect rect = [textToMeasure boundingRectWithSize:CGSizeMake(width, MAXFLOAT)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:attributes
context:nil];
I am Updating a iOS5 project to storybaord and compatible to run with iOS6 / iOS7. my table view have 4 sections and each section have data of different length which may or may not be displayed as a single line.
the old code is some thing like this and I get a warning for the statement
CGSize size = [productToShow.pDesc sizeWithFont:self.lblHidden.font constrainedToSize:self.lblHidden.frame.size lineBreakMode:NSLineBreakByWordWrapping];
warning
sizeWithFont:constrainedToSize:lineBreakMode:is first deprecated in iOS7
so I have tried usingboundingRectWithSize:options:attributes:context: as suggested by the compiler.
but the code seems to be more complicated: apple wouldn't be making simpler things difficult. if some one can see my codes and suggest the best method or a better and simple method it would be of grate help to me and the community.
iOS5 code with XIBs
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0)
{
NSString *tempPointStr = [self.shortDescArray objectAtIndex:indexPath.row];
self.lblHidden.frame = CGRectMake(58, 0, 945, 9999);
self.lblHidden.text = tempPointStr;
CGSize size = [tempPointStr sizeWithFont:self.lblHidden.font
constrainedToSize:self.lblHidden.frame.size
lineBreakMode:NSLineBreakByWordWrapping];
if (size.height < 50.0f)
{
return 50.0f;
}
else
{
return size.height;
}
}
elseif(indexPath.section == 1)
{
...
}
else
{
...
}
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0)
{
static NSString *tempPoint = #"ProductPointsCell";
ProductPointsCell *cell = (ProductPointsCell*)[tableView dequeueReusableCellWithIdentifier:tempPoint];
if (cell == nil)
{
NSArray* nib = [[NSBundle mainBundle] loadNibNamed:#"ProductPointsCell_iPad" owner:self options:nil];
cell = [nib objectAtIndex:0];
cell.showsReorderControl = NO;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.backgroundColor=[UIColor clearColor];
cell.lblPoint.font = [UIFont fontWithName:#"Arial-BoldMT" size:18.0f];
}
NSString *tempPointStr = [self.shortDescArray objectAtIndex:indexPath.row];
cell.lblPoint.text = tempPointStr;
self.lblHidden.frame = CGRectMake(58, 0, 945, 9999);
self.lblHidden.text = tempPointStr;
CGSize size = [tempPointStr sizeWithFont:self.lblHidden.font
constrainedToSize:self.lblHidden.frame.size
lineBreakMode:NSLineBreakByWordWrapping];
if (size.height < 50.0f)
{
cell.lblPoint.frame = CGRectMake(58, 0, 945, 50.0f);
}
else
{
cell.lblPoint.frame = CGRectMake(58, 0, 945, size.height);
}
return cell;
}
elseif(indexPath.section == 1)
{
...
}
else
{
...
}
}
where as the same code in :
iOS6/7 codes with storybaord
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0)
{
NSString *tempPointStr = (self.shortDescArray)[indexPath.row];
self.lblHidden.frame = CGRectMake(58, 0, 945, 9999);
self.lblHidden.text = tempPointStr;
CGSize constraint = CGSizeMake(945, 9999.0f);
NSDictionary * attributes = [NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:14.0f] forKey:NSFontAttributeName];
NSAttributedString *attributedText = [[NSAttributedString alloc]initWithString:self.lblHidden.text attributes:attributes];
CGRect rect = [attributedText boundingRectWithSize:constraint options:NSStringDrawingUsesLineFragmentOrigin context:nil];
CGSize size = rect.size;
if (size.height < 50.0f)
{
return 50.0f;
}
else
{
return size.height;
}
}
elseif(indexPath.section == 1)
{
...
}
else
{
...
}
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0)
{
static NSString *tempPoint = #"ProductPointsCell";
ProductPointsCell *cell = (ProductPointsCell*)[tableView dequeueReusableCellWithIdentifier:tempPoint];
cell.showsReorderControl = NO;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.backgroundColor=[UIColor clearColor];
cell.pointLbl.font = [UIFont fontWithName:#"Arial-BoldMT" size:18.0f];
[cell.pointLbl setLineBreakMode:NSLineBreakByWordWrapping];
[cell.pointLbl setNumberOfLines:0];
NSString *tempPointStr = (self.shortDescArray)[indexPath.row];
cell.pointLbl.text = tempPointStr;
CGSize constraint = CGSizeMake(945,9999.0f);
NSAttributedString *attributedText = [[NSAttributedString alloc]initWithString:cell.pointLbl.text attributes:#{NSFontAttributeName: [UIFont systemFontOfSize:17.0f]}];
CGRect rect = [attributedText boundingRectWithSize:constraint options:NSStringDrawingUsesLineFragmentOrigin context:nil];
CGSize size = rect.size;
if (size.height < 50.0f)
{
cell.pointLbl.frame = CGRectMake(58, 0, 945, 50.0f);
}
else
{
cell.pointLbl.frame = CGRectMake(58, 0, 945, size.height);
}
return cell;
}
elseif(indexPath.section == 1)
{
...
}
else
{
...
}
}
The purpose of these codes are to make the data displayed in a single line when it fits within a single line and when it doesn't the cell height is adjusted and the data is displayed as a multiline cell.
Also correct me if I should keep the autolayout on or off and should I set any parameters in the storyboard while converting.
if some one can suggest a better/faster and easier way please do so with examples.
Try it without NSAttributedString...this works for me:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
{
NSManagedObject *obj = [results objectAtIndex:indexPath.row];
NSString *text = [obj valueForKey:#"name"];
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:FONT_SIZE], NSFontAttributeName, nil];
CGSize constraint = CGSizeMake(CELL_CONTENT_WIDTH - (CELL_CONTENT_MARGIN * 2), 20000.0f);
CGSize size = [text boundingRectWithSize:constraint options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attributes context:nil].size;
CGFloat height = MAX(size.height, 45.0f);
return height ;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"Cell";
TVCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[TVCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
NSManagedObject *obj = [results objectAtIndex:indexPath.row];
NSString *text = [obj valueForKey:#"name"];
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:FONT_SIZE], NSFontAttributeName, nil];
CGSize constraint = CGSizeMake(CELL_CONTENT_WIDTH - (CELL_CONTENT_MARGIN * 2), 20000.0f);
CGSize size = [text boundingRectWithSize:constraint options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attributes context:nil].size;
[cell.cellText setText:text];
[cell.cellText setFrame:CGRectMake(CELL_CONTENT_MARGIN, 0.0, CELL_CONTENT_WIDTH - (CELL_CONTENT_MARGIN * 2), MAX(size.height, 45.0f))];
return cell;
}
In TVCell.m:
self.cellText = [[UILabel alloc] initWithFrame:CGRectZero];
[self.cellText setLineBreakMode:NSLineBreakByWordWrapping];
[self.cellText setMinimumScaleFactor:FONT_SIZE];
[self.cellText setNumberOfLines:0];
[self.cellText setFont:[UIFont systemFontOfSize:FONT_SIZE]];
self.cellText.textColor = [UIColor colorWithRed:64/255.0 green:59/255.0 blue:59/255.0 alpha:1.0];
[self.contentView addSubview:self.cellText];
When I load UITabelView on viewDidLoad it does not show proper data in cells, but when I scroll the tabelview it sets proper data. What's wrong in my code?
Here the code I use.
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
CustomCell *cell = [_AnswerKeyTable dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
NSArray *topLevelObject = [[NSBundle mainBundle] loadNibNamed:#"CustomCell" owner:self options:nil];
for(id currentObject in topLevelObject)
{
if([currentObject isKindOfClass:[UITableViewCell class]])
{
cell = (CustomCell*)currentObject;
}
}
}
ModelInfo *info = [mArray objectAtIndex:indexPath.row];
CGSize constraint = CGSizeMake(212, 20000.0f);
NSString *temp=[NSString stringWithFormat:#"%# (%#)",info.your_answer,info.answer_status];
CGSize question_size = [info.question sizeWithFont:[UIFont systemFontOfSize:FONT_SIZE] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
CGSize your_answer_size = [temp sizeWithFont:[UIFont systemFontOfSize:FONT_SIZE] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
CGSize correct_answer_size = [info.correct_answer sizeWithFont:[UIFont systemFontOfSize:FONT_SIZE] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
NSString * ans_string;
if([info.answer_status isEqualToString:#"Correct answered"])
{
ans_string = [NSString stringWithFormat:#"%#(<font color=\"#7EBA00\"><b>%#</b></font>)",info.your_answer,info.answer_status];
cell.lblCorrectAnswer.hidden = YES;
cell.lblC_Ans.hidden = YES;
}else if([info.answer_status isEqualToString:#"Not answered"]){
ans_string = [NSString stringWithFormat:#"<font color=\"#FF0000\"><b>%#</b></font>)",info.answer_status];
cell.lblCorrectAnswer.hidden = NO;
cell.lblC_Ans.hidden = NO;
cell.lblCorrectAnswer.text =info.correct_answer;
[cell.lblCorrectAnswer setFrame:CGRectMake(103,your_answer_size.height+question_size.height+9,212,correct_answer_size.height)];
[cell.lblC_Ans setFrame:CGRectMake(cell.lblC_Ans.frame.origin.x,your_answer_size.height+question_size.height+9,cell.lblC_Ans.frame.size.width,21)];
}else{
ans_string = [NSString stringWithFormat:#"%#(<font color=\"#FF0000\"><b>%#</b></font>)",info.your_answer,info.answer_status];
cell.lblCorrectAnswer.hidden = NO;
cell.lblC_Ans.hidden = NO;
cell.lblCorrectAnswer.text =info.correct_answer;
[cell.lblCorrectAnswer setFrame:CGRectMake(103,your_answer_size.height+question_size.height+9,212,correct_answer_size.height)];
[cell.lblC_Ans setFrame:CGRectMake(cell.lblC_Ans.frame.origin.x,your_answer_size.height+question_size.height+9,cell.lblC_Ans.frame.size.width,21)];
}
cell.lblQuestion.text = info.question;
cell.lblYourAnswer.text = ans_string;
cell.lblYourAnswer.attributedText=[OHASBasicHTMLParser attributedStringByProcessingMarkupInAttributedString:cell.lblYourAnswer.attributedText];
cell.lblQue.text = [NSString stringWithFormat:#"Question %d",indexPath.row+1];
[cell.lblQuestion setFrame:CGRectMake(103, 3,212,question_size.height)];
[cell.lblYourAnswer setFrame:CGRectMake(103,cell.lblQuestion.frame.size.height+6,212,your_answer_size.height)];
[cell.lblAns setFrame:CGRectMake(cell.lblAns.frame.origin.x,cell.lblQuestion.frame.size.height+6,cell.lblAns.frame.size.width,21)];
[cell.view setFrame:CGRectMake(5,1,310,cell.lblQuestion.frame.size.height+cell.lblYourAnswer.frame.size.height+cell.lblCorrectAnswer.frame.size.height)];
[cell setFrame:CGRectMake(0,0,320,cell.view.frame.size.height)];
[cell setFrame:CGRectMake(0,0,320,cell.frame.size.height+10)];
return cell;
}
You can't set the frame of a cell -tableView:cellForRowAtIndexPath:. That is handled automatically by the table view.
To tell the table view the height needed for a cell, use -tableView:heightForRowAtIndexPath:.
I want to parse xml and show the title, description and image in table cell.
I did following code, but if image is not available, then also garbage image is displaying on cell.
I did code to hide it but image view not hiding.
Also I set frame to zero values but image view with garbage image is displaying:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
appDelegate = (AppDelegate_iPhone *) [[UIApplication sharedApplication] delegate];
if (section == 0) {
return [appDelegate.TrendDataArray count];
}else {
return [appDelegate.MyDataArray count];
}
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
if(section == 0)
return #" Trending ";
else
return #" Live Feeds ";
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UILabel *lblTitle;
UILabel *lbldescription;
UIImageView *imgViewTemp;
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
lblTitle = [[UILabel alloc] initWithFrame:CGRectZero];
[lblTitle setLineBreakMode:UILineBreakModeWordWrap];
[lblTitle setNumberOfLines:2];
lblTitle.textAlignment= UITextAlignmentLeft;
[lblTitle setFont:[UIFont fontWithName:#"Helvetica-Bold" size:FONT]];
lblTitle.textColor=[UIColor blackColor];
[lblTitle setTag:1];
lbldescription = [[UILabel alloc] initWithFrame:CGRectZero];
[lbldescription setLineBreakMode:UILineBreakModeWordWrap];
[lbldescription setNumberOfLines:3];
lbldescription.textAlignment= UITextAlignmentLeft;
[lbldescription setFont:[UIFont fontWithName:#"Helvetica" size:FONT2]];
lbldescription.textColor=[UIColor grayColor];
[lbldescription sizeToFit];
[lbldescription setTag:2];
imgViewTemp = [[UIImageView alloc] initWithFrame:CGRectZero];
[imgViewTemp setTag:3];
[cell.contentView addSubview:lblTitle];
[cell.contentView addSubview:lbldescription];
//[imgViewTemp release];
[lblTitle release];
[lbldescription release];
}
// Configure the cell...
if (indexPath.section == 0) {
appDelegate=(AppDelegate_iPhone *)[[UIApplication sharedApplication] delegate];
objXmlParse_Attributes= [appDelegate.TrendDataArray objectAtIndex:indexPath.row];
}else if (indexPath.section == 1) {
appDelegate=(AppDelegate_iPhone *)[[UIApplication sharedApplication] delegate];
objXmlParse_Attributes= [appDelegate.MyDataArray objectAtIndex:indexPath.row];
}
NSString *text = objXmlParse_Attributes.CommenUrlTitle;
text = [text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *text2 = objXmlParse_Attributes.CommenUrlDescription;
text2 = [text2 stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
CGSize constraint = CGSizeMake(WIDTH - (MARGIN * 2), 20000.0f);
CGSize size = [text sizeWithFont:[UIFont fontWithName:#"Helvetica-Bold" size:FONT] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
CGSize size2 = [text2 sizeWithFont:[UIFont fontWithName:#"Helvetica" size:FONT2] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
NSString *link = [NSString stringWithFormat:#"%#", objXmlParse_Attributes.CommenUrlImage];
//imgViewTemp = [[UIImageView alloc] initWithFrame:CGRectZero];
//[UIImage imageNamed:#"noimage.png"]
if([link isEqualToString:#"No image"] || [link isEqualToString:#"no image"]){
link = #"";
if ([link isEqualToString:#""]) {
imgViewTemp = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,0,0)];
//[imgViewTemp release];
lblTitle = (UILabel*)[cell.contentView viewWithTag:1];
[lblTitle setText:text];
[lblTitle setFrame:CGRectMake(MARGIN+3,MARGIN, WIDTH-110+83,MIN(size.height,30))];
lbldescription = (UILabel*)[cell.contentView viewWithTag:2];
[lbldescription setText:text2];
[lbldescription setFrame:CGRectMake(MARGIN+3,MARGIN + MIN(size.height,30),WIDTH-110+83,MIN(size2.height,40))];
}
}
else{
//imgViewTemp = (UIImageView*)[cell.contentView viewWithTag:3];
imgViewTemp = [[UIImageView alloc] initWithFrame:CGRectMake(7,11,73,60)];
[imgViewTemp setImageWithURL:[NSURL URLWithString:link] placeholderImage:nil];
//image1.hidden=FALSE;
lblTitle = (UILabel*)[cell.contentView viewWithTag:1];
[lblTitle setText:text];
[lblTitle setFrame:CGRectMake(MARGIN + 83, MARGIN, WIDTH-110,MIN(size.height,30))];
lbldescription = (UILabel*)[cell.contentView viewWithTag:2];
[lbldescription setText:text2];
[lbldescription setFrame:CGRectMake(MARGIN + 83, MARGIN + MIN(size.height,30),WIDTH-110,MIN(size2.height,40))];
[cell.contentView addSubview:imgViewTemp];
}
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
Hey just search for tutorial to make table. Dont ask such query in this portion, there is a lot of example for UITableView...I hope you understand.