Wednesday, 14 December 2011

Adding objects in to an array and displaying it in a table view cell-iPhone

- (void)viewDidLoad {
    [super viewDidLoad];

array1 =[[NSMutableArray alloc]initWithObjects:@"Sources of Stress",@"Stress Symptoms",@"Stress Resilience",nil];
array2 =[[NSMutableArray alloc]initWithObjects:@"Mood",@"Notes",nil];

}

//In side the cellfor row at indexpath

f(indexPath.section==0)
    {
        //cell.textLabel.textAlignment=UITextAlignmentCenter;
        cell.textLabel.text=[array1 objectAtIndex:indexPath.row];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    else
    {
        //cell.textLabel.textAlignment=UITextAlignmentCenter;
        cell.textLabel.text=[array2 objectAtIndex:indexPath.row];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    }
    return cell;



No comments:

Post a Comment