First of I’m very sorry to ask this doubt.
I created a table view cell and tried to align it to center.But this is doing nothing.just align in left itself.
This is the code i used.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
if(indexPath.section == 0){
SDSCaseListCustomCell *customCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// if (customCell == nil)
{
NSArray *cells =[[NSBundle mainBundle] loadNibNamed:@"SDSCaseListCustomCell" owner:nil options:nil];
for (UIView *view in cells)
{
if([view isKindOfClass:[UITableViewCell class]])
{
customCell = (SDSCaseListCustomCell*)view;
}
}
}
SDSCase *cases = [caseList objectAtIndex:indexPath.row];
customCell.doctor.text = cases.referredDoctor;
customCell.hospital.text = cases.hospital;
//customCell.time.text = cases.referredDoctor;
customCell.caseId.text =cases.caseId;
return customCell;
}
else
{
UITableViewCell *loadMore = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (loadMore == nil)
{
loadMore = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
loadMore.textLabel.text = @"loadMore";
loadMore.textLabel.textAlignment = UITextAlignmentCenter;
return loadMore;
}
}
Can anybody please help me where I’m going wrong.
Thanks in advace.
use indentationLevel
Edit:
If you want to you can create your own label and added as a subview to the contentView. You can not change the alignment of the textLabel the alignment is controlled by the UITableViewCellStyleSubtitle