#pragma mark Table view methods
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 3;
}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 3;
}
// 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:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
if(selected)
{
if(indexPath == selectedIndex)
{
cell.textLabel.text = @"selected";
}
else {
cell.textLabel.text=@"not selected";
}
}
else {
cell.textLabel.text = @"not selected";
}
// Configure the cell.
return cell;
}
// Override to support row selection in the table view.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
selected = YES;
selectedIndex = indexPath;
[tableView reloadData];
}
#pragma mark Table view methods
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 3;
}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 3;
}
// 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:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
if(selected)
{
switch (indexPath.section) {
case 0:
if(indexPath == selectedIndex0)
{
cell.textLabel.text = @"selected";
}
else {
cell.textLabel.text=@"not selected";
}
break;
case 1:
if(indexPath == selectedIndex1)
{
cell.textLabel.text = @"selected";
}
else {
cell.textLabel.text=@"not selected";
}
break;
case 2:
if(indexPath == selectedIndex2)
{
cell.textLabel.text = @"selected";
}
else {
cell.textLabel.text=@"not selected";
}
break;
default:
break;
}
}
else {
cell.textLabel.text = @"not selected";
}
// Configure the cell.
return cell;
}
// Override to support row selection in the table view.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
selected = YES;
switch (indexPath.section) {
case 0:
selectedIndex0 = indexPath;
case 1:
selectedIndex1 = indexPath;
case 2:
selectedIndex2 = indexPath;
break;
default:
break;