开发者

UITableViewCell and UITableView (did select a row) navigation to otherViewcontroller

I hav a UITableViewCell and UITableView in a single view.Clicking on particular row of UITableView ,It navigates to anotherViewController.But I am not able to navigate to otherViewController on clicking UITableViewCell.How can i do this??

For UITableView I am using 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];
}

UITableViewCell and UITableView (did select a row) navigation to otherViewcontroller

What should I do for UITableViewCell??

UITableViewCell and UITableView (did select a row) navigation to otherViewcontroller


Edit:

what you want to push is not a UITableViewCell

It's another View.

You can say

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

but I never see any code passing to another cell.

A cell is used to customize the look of you UITableView.

Add:

I think the if statement is not useful here.

Do you mean

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

or an empty view is going to be passed any way.


 (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];
 }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜