将现有的tableview行号与新的tableview行号进行比较

时间:2011-06-16 08:01:07

标签: uitableview didselectrowatindexpath catransition

我正在尝试将pageCurl或pageUnCurl功能实现到splitviewcontroller应用程序中。基本上我需要跟踪tableView中哪一行弹出一个新视图,以便根据页面的相对位置卷曲或展开页面。

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

    /*
     Create and configure a new detail view controller appropriate for the selection.
     */
    NSUInteger row = indexPath.row;
    NSUInteger pagenumber=1;
    UIViewController <SubstitutableDetailViewController> *whatdetailViewController = nil;


    if (row == 0) {

        DetailViewController *newDetailViewController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:nil];
        whatdetailViewController = newDetailViewController;

            case 0: pagenumber++;

            case 1: pagenumber--;

        NSLog(@"pagenumber %i",pagenumber);
        NSLog(@"row %i",row);
        if (pagenumber<row){
            [self pageUnCurl]; 
        }else{
            [self pageCurl];  
        }
    }

    if (row == 1) {

        SecondDetailViewController *newDetailViewController = [[SecondDetailViewController alloc] initWithNibName:@"SecondDetailViewController" bundle:nil];
        whatdetailViewController = newDetailViewController;


            case 0: pagenumber++;

            case 1: pagenumber--;

        NSLog(@"2pagenumber %i",pagenumber);
        NSLog(@"2row %i",row);
        if (pagenumber<row){
            [self pageUnCurl]; 
        }else{
            [self pageCurl];  
        }

     }

根据行选择,有一种简单的向上或向下计数方法吗? 谢谢

更新 - 这工作

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

    /*
     Create and configure a new detail view controller appropriate for the selection.
     */
    NSUInteger row = indexPath.row;
    UIViewController <SubstitutableDetailViewController> *whatdetailViewController = nil;


    if (row == 0) {{

        DetailViewController *newDetailViewController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:nil];
        whatdetailViewController = newDetailViewController;
        if (exitRow>row){
        [self pageUnCurl];  
        } else {
            [self pageCurl];
            }

        }
        exitRow=row;
    }
    if (row == 1) {{

        SecondDetailViewController *newDetailViewController = [[SecondDetailViewController alloc] initWithNibName:@"SecondDetailViewController" bundle:nil];
        whatdetailViewController = newDetailViewController;
        if (exitRow>row){
            [self pageUnCurl];  
        } else {
            [self pageCurl];
            }

        }
        exitRow=row;

    }
}

0 个答案:

没有答案