views:

24

answers:

1

I had a page control(UIPageControl) on a view (UIViewController) with table view (UITableView) on each page, each page have own table and can go to different view controller. i add the codes in "didSelectRowAtIndexPath" which can go to next level, is works perfect when i test it in a table view by itself, but it doesn't works when i have page controller with it.

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

    [tableView deselectRowAtIndexPath:indexPath animated:YES];

    if (pageNumber == 0) {

        PicturesViewController *picturesView = [[PicturesViewController alloc] init];
        [self.navigationController pushViewController:picturesView animated:YES];

        [picturesView release];

    } else if (pageNumber == 1) {

        PictureDetailViewController *pictureDetailView = [[PictureDetailViewController alloc] init];
        [self.navigationController pushViewController:pictureDetailView animated:YES];

        [pictureDetailView release];

    } else if (pageNumber == 2) {

        MessagesViewController *messagesView = [[MessagesViewController alloc] init];
        [self.navigationController pushViewController:messagesView animated:YES];

        [messagesView release];

    }

}

here is the code, if view directly to this table view this code is work,

how can i make it work under the pagecontrol??

A: 

I'm not entirely sure what you're asking but it looks like the "pageNumber" variable isn't the condition you are looking for.

Instead, try replacing the pageNumber == conditions with indexPath.row == 0, 1, 2 etc.

Tom