我有两个 UIViewController,分别命名为 ViewControllerA 和 ViewControllerB 。 ViewControllerA 是父类,ViewControllerB 是子类,由 ViewControllerA 类中的 [self.navigationController pushViewController:viewControllerB animated:YES]; 查看。在 ViewControllerB 类中,我隐藏了 NavigationBar。在按钮操作中,我编写了从 ViewControllerB [self.navigationController popViewControllerAnimated:YES]; 来的 ViewControllerA。现在,我想使用交换操作(滚动到上一个屏幕)而不是使用 UIButton 从 ViewControllerB 来 ViewControllerA。我怎样才能做到这一点?谁能给我任何建议或想法?提前致谢。
Best Answer-推荐答案 strong>
在子 Controller 中使用它
- (void)viewDidLoad
{
UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self actionselector(handleSwipeFrom];
[recognizer setDirectionUISwipeGestureRecognizerDirectionRight | UISwipeGestureRecognizerDirectionDown | UISwipeGestureRecognizerDirectionLeft | UISwipeGestureRecognizerDirectionUp)];
[[self view] addGestureRecognizer:recognizer];
[recognizer release];
[super viewDidLoad];
}
-(void)handleSwipeFromUISwipeGestureRecognizer *)recognizer
{
[self.navigationController popViewControllerAnimated:YES];
NSLog(@"Swipe received.");
}
根据需要使用方向..
快乐编码...
关于iphone - 如何使用滚动 Action 从 subview Controller 中获取父 View Controller ?,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/8999090/
|