将现有表视图行号与新表视图行号进行比较
我正在尝试将 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论