iphone页,导航上的UITableView

时间:2011-05-11 10:38:42

标签: iphone

我制作了一个显示钻石主要细节的表格 当我选择单行时,页面将导航到第二页“详细信息页面” 显示精选钻石的全部细节.. (我使用单个UITableViewCell显示完整的钻石细节)

第一页从第二页导航。我的代码是

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath 
*)indexPath {

    self.DiamondDetail = [[DiamondDetail alloc] init];
    DimEntity *Dim = [DimArray objectAtIndex:indexPath.row];
    _DiamondDetail.Diamond = Dim;
    self.title = @"    Detail    ";
    [self.navigationController pushViewController: _DiamondDetail animated:YES];

    [self.tableView deselectRowAtIndexPath:indexPath animated:YES]; 
}

现在,输出细节页面 在NavigationBar左侧有一个按钮自动生成说“细节” 单击该按钮页面再次导航到第一页..

但是...

我想......

当用户在IPad-IPhone Surface / UITableviewCell上移动他/她的手指时

从右到左然后页面也应该导航..

我怎么能

1 个答案:

答案 0 :(得分:1)

为此你必须学习UISwipeGestureRecognizer

    -(void)viewDidLoad {
            [super viewDidLoad];

        // Swipe Left
        UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc]
            initWithTarget:self action:@selector(handleSwipeLeft:)];

        swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
        [self.view addGestureRecognizer:swipeLeft];
        [swipeLeft release];

        // Swipe Right
        UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc]
            initWithTarget:self action:@selector(handleSwipeRight:)];

        swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
        [self.view addGestureRecognizer:swipeRight];
        [swipeRight release];
    }   
- (void)handleSwipeLeft:(UISwipeGestureRecognizer *)recognizer {
 [self.navigationController pushViewController: _DiamondDetail animated:YES]
}

- (void)handleSwipeRight:(UISwipeGestureRecognizer *)recognizer {
[self.navigationController pushViewController: _DiamondDetail animated:YES]
}