I am having a NSArray of size 11 as it formed below.
labels = [NSMutableArray arrayWithObjects:@"DIN #",@"Brand Name",@"Full Name",
@"Strength",
@"Medication Type",
@"Presciption ID",
@"Next Dosage",
@"Required Dosage",
@"ada",
@"dasdada",
@"dasdasad",
nil];
but when i am displaying this array in tableview cell Using this code.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dueueReusableCellWithIdentifier:CellIdentifier];
UILabel* nameLabel = nil;
if(cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];nameLabel = [[UILabel alloc] initWithFrame:CGRectMake( 7.0, 10.0, 160.0, 44.0 )];
nameLabel.text =[labels objectAtIndex:indexPath.row];
nameLabel.lineBreakMode = UILineBreakModeWordWrap;
nameLabel.numberOfLines =0;
[nameLabel sizeToFit];
CGSize expectedlabelsize = [nameLabel.text sizeWithFont:nameLabel.font constrainedToSize:nameLabel.frame.size lineBreakMode:UILineBreakModeWordWrap];
CGRect newFrame =nameLabel.frame;
newFrame.size.height =expectedlabelsize.height;
[cell.contentView addSubview: nameLabel];
return cell;}
O/P is as below .
DIN
Brand Name
Full Name
Strength
Medication Type
Presciption ID
Next Dosage
Required Dosage
DIN
Brand Name
Full Name
see after required Dosage again DIN,Brand Name,Full Name showing ,which are already shown
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…