[英]Perform NSRegularExpression action in a selected tableview cell
[英]TableView - action when cell is selected
我有一些單元格可以執行定序操作,但是我希望一個單元格可以將當前用戶注銷。 如何將此操作設置為單個單元格?
蒂姆,蒂姆
您可以實現shouldPerformSegueWithIdentifier:sender:,並為要注銷用戶的單元格的indexPath返回NO。 sender參數將是該單元格,因此您可以從中獲取indexPath。 如果您希望第一個單元注銷用戶,則可以執行此操作,
- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(UITableViewCell *)sender {
NSIndexPath *path = [self.tableView indexPathForCell:sender];
if (path.row == 0) {
// log out the user here
return NO;
}else{
return YES;
}
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// User selected a row, so check if it's the logout row or not
if (indexPath.row == logoutRowIndex) {
// Logout
[self logout];
} else {
// Perform segue
[self performSegueWithIdentifier:@"segueIdentifier"];
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.