Compare existing tableview row number to new tableview row number
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 appropri开发者_开发百科ate 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;
}
}
精彩评论