1

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

    }
}
4

0 回答 0