如何在iPhone SDK中通过滑动推送/弹出控制器?
目前,我正在开发一个iPhone应用程序,通过滑动手势识别器在两个控件之间导航 应用结构是这样的 为此,我首先加载日历屏幕,并在其视图上加载,然后使用PushViewController加载主屏幕。在主屏幕上,如果用户向左滑动,则使用PopViewController显示日历屏幕;如果用户向右滑动,则使用PushViewController显示listview屏幕。这很好用 现在的问题是,在我的listview屏幕上,我使用的是UITableViewController,手势识别器无法完美工作,有时它无法滑动 如何在这些屏幕之间完美地滑动,我想滑动与滚动视图滚动相同如何在iPhone SDK中通过滑动推送/弹出控制器?,iphone,uiscrollview,uigesturerecognizer,swipe,pushviewcontroller,Iphone,Uiscrollview,Uigesturerecognizer,Swipe,Pushviewcontroller,目前,我正在开发一个iPhone应用程序,通过滑动手势识别器在两个控件之间导航 应用结构是这样的 为此,我首先加载日历屏幕,并在其视图上加载,然后使用PushViewController加载主屏幕。在主屏幕上,如果用户向左滑动,则使用PopViewController显示日历屏幕;如果用户向右滑动,则使用PushViewController显示listview屏幕。这很好用 现在的问题是,在我的listview屏幕上,我使用的是UITableViewController,手势识别器无法完美工作,
请为我提供一些解决方案。如果您的应用程序安装在iOS 3.2或更高版本上,您可以使用UISwipegestureRecognitor执行此操作,如下所示
//Add Table
UITableView *table = [[UITableView alloc] initWithFrame:CGRectMake(0, 20, 320, 460)];
table.dataSource=self;
table.delegate=self;
[table reloadData];
[self.view addSubview:table];
[table release];
//Add Gesture Recognizer
swipeLeftRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom)];
[table addGestureRecognizer:swipeLeftRecognizer];
[swipeLeftRecognizer release];
在你的控制器的某个地方
-(void)handleSwipeFrom {
if (swipeLeftRecognizer.direction == UISwipeGestureRecognizerDirectionRight) {
// Your code here to go back to the main view
}
}
这只会对右击做出反应,并让您的桌子表现正常。希望这有帮助!: 如果您的应用程序安装在iOS 3.2或更高版本上,您可以使用UISwipegestureRecognitor执行此操作,如下所示
//Add Table
UITableView *table = [[UITableView alloc] initWithFrame:CGRectMake(0, 20, 320, 460)];
table.dataSource=self;
table.delegate=self;
[table reloadData];
[self.view addSubview:table];
[table release];
//Add Gesture Recognizer
swipeLeftRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom)];
[table addGestureRecognizer:swipeLeftRecognizer];
[swipeLeftRecognizer release];
在你的控制器的某个地方
-(void)handleSwipeFrom {
if (swipeLeftRecognizer.direction == UISwipeGestureRecognizerDirectionRight) {
// Your code here to go back to the main view
}
}
这只会对右击做出反应,并让您的桌子表现正常。希望这有帮助!: 经过长时间的谷歌搜索,我找到了一个解决方案。我正在使用3个屏幕宽度的滚动视图,并在第一个屏幕框上添加日历xib视图,在第二个屏幕框上添加主页xib视图,然后在第三个屏幕框上添加列表xib视图,用此创建UINavigationController*navigationHome; 家长控制器id;
在主屏幕上,从scrollview管理主屏幕导航,并对其他控制器使用相同的技术,这对我很有用。在长时间的谷歌搜索后,我找到了一个解决方案。我正在使用3个屏幕宽度的滚动视图,并在第一个屏幕框上添加日历xib视图,在第二个屏幕框上添加主页xib视图,然后在第三个屏幕框上添加列表xib视图,用此创建UINavigationController*navigationHome; 家长控制器id; 在主屏幕上,从scrollview管理主屏幕导航,并对其他控制器使用相同的技术,这对我来说很好