简体   繁体   中英

switch to modal view by clicking on tableview cell (newbie)

I know this is a simple question, but I can't find the answer. So how can I modally switch to a new view by selecting a UITableViewCell ?

I know that I can use something like this code:

if (cell.isSelected)
    {
         [self performSegueWithIdentifier:@"someSegue" sender:self];
    }

I must check if this cell is Selected for some period of time and because of that I don't know where in my UITableViewController I should use this code.

You want to implement the tableView:didSelectRowAtIndexPath: delegate method. This will be called when you select a row of your table view.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
     [self performSegueWithIdentifier:@"someSegue" sender:self];
}

More details can be found in the Table View Programming Guide for iOS

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM