将现有表视图行号与新表视图行号进行比较

发布于 2024-11-15 20:00:49 字数 2680 浏览 3 评论 0原文

我正在尝试将 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;

    }
}

I am trying to implement pageCurl or pageUnCurl functionality into a splitviewcontroller app. Basically I need to keep track of which row in a tableView is popping a new view so that it will curl or uncurl the page depending on its relative position.

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

     }

Is there an easy way to count up or down depending on the row selection?
Thank you

Update-
This works

- (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;

    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文