UITableViewCell and UITableView (made a row selection) for navigation in otherViewcontroller

I hav a UITableViewCelland UITableViewin a single view. By clicking on a specific row UITableView, it will go to anotherViewController. But I can not go to otherViewController when clicked UITableViewCell. How can i do this?

For UITableViewI use this code:

-(void)pushView1:(id)sender{
    if(edController == nil)
    edController = [[EditableDetailCell alloc] initWithNibName:@"EditableDetailCell" bundle:[NSBundle mainBundle]];
    [self.navigationController pushViewController:edController animated:YES];
}
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    UITableViewCell *tbcel;
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
    }
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    tbcel.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    tbcel.layer.cornerRadius = 15;
    tbcel.text = aBook.Name;
    switch(indexPath.section)
    {
         case 0:
            cell.text = aBook.Address;
            break;
        case 1:
            cell.text = aBook.Phone;
            break;
        case 2:
            cell.text = aBook.Purchase;
    }
    return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(edController == nil)
    edController = [[EditableDetailCell alloc] initWithNibName:@"EditableDetailCell" bundle:[NSBundle mainBundle]];
    [self.navigationController pushViewController:edController animated:YES];
}

enter image description here

What to do for UITableViewCell?

ist is tableviewcell and below it in block is tableview

+5
source share
2 answers

Edit:

what you want to click is not a UITableViewCell

This is a different view.

you can say

YourCustomView *view = [[YourCustomView alloc] init];
[self.navigationController pushViewController:view animated:Yes];

but I never see any code moving to another cell.

The cell is used to customize the appearance of the UITableView.

Add

I think the if statement is not useful here.

You mean

if(edController == nil){
    edController = [[EditableDetailCell alloc] initWithnibName:@"EditableDetailCell" bundle:[NSBundle mainBundle]];
    [self.navigationController pushViewController:edController animated:YES];
}

.

+1
 (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
 {
    NSLog("Selected Row %d", indexPath.row);
    YourNextViewController *objVC = (YourNextViewController *)[storyboard instantiateViewControllerWithIdentifier:@"ViewControllerIdentifier"];
   [self presentViewController: objVC animated:YES completion:nil];
 }
+1

All Articles