Reputation: 43
i have a menu that contain 6 cells 1st one contain UIViewController
the second contain UITableView
when i click the first cell a new page appear,and it contain a button when i click this button i want access to the second cell from the Menu, that contain a tableView
Upvotes: 2
Views: 1145
Reputation: 736
// use this code for to Refresh or delete or insert TableviewCell
// reloading cell
NSIndexPath *tmpIndexpath=[NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:tmpIndexpath, nil] withRowAnimation:UITableViewRowAnimationTop];
// inserting cell
NSIndexPath *tmpIndexpath=[NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObjects:tmpIndexpath, nil] withRowAnimation:UITableViewRowAnimationTop];
// deleting cell
NSIndexPath *tmpIndexpath=[NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObjects:tmpIndexpath, nil] withRowAnimation:UITableViewRowAnimationBottom];
Upvotes: 3
Reputation: 47059
Write following coed in your UIButton
Tapped Method.
-(void) ButtonTapped:(UIButton *) sender
{
NSIndexPath *indexpathNew = [self.tblView indexPathForCell:(UITableViewCell *)[sender superview]];
NSLog(@"%@",indexpathNew.row);
}
indexpathNew
is return indextPath
of selected button of cell.
Try my code i might be helpful to you.
Upvotes: 1
Reputation: 3082
As much i understand your question you want to move from a tableview to other view on click..So,you have to use code similar to this..
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
Detail *img1=[[Detail alloc]initWithNibName:@"Detail" bundle:Nil];
img1.labelString = [titleArray objectAtIndex:indexPath.row];
[self presentViewController:img1 animated:YES completion:nil];
}
Upvotes: 1