IOS如何摇动改变View
我已经知道如何使用下面的代码捕获摇动手势
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if ( event.subtype == UIEventSubtypeMotionShake )
{
// Put in code here to handle shake
NSLog(@"Device Shaked");
}
if ( [super respondsToSelector:@selector(motionEnded:withEvent:)] )
[super motionEnded:motion withEvent:event];
}
NSLog 显示它确实收到了摇动
,但如何推送另一个视图,或返回到最后一个视图,因为我们知道下面的代码只能在 ViewController 类中使用这个Leavesview不是View类,而是由LeavesviewController处理,并且我在另一个PDFViewController中使用这个viewController来显示,那么我怎样才能让它跳转到另一个视图或关闭回来???
UIViewController *myView = [[UIViewController alloc]init];
[self.navigationController pushViewController:myView animated:YES];
I've already know how to catch the shake gesture with the code below
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if ( event.subtype == UIEventSubtypeMotionShake )
{
// Put in code here to handle shake
NSLog(@"Device Shaked");
}
if ( [super respondsToSelector:@selector(motionEnded:withEvent:)] )
[super motionEnded:motion withEvent:event];
}
The NSLog shows that it did received the shake
but how to push another view,or back to the last view, as we know the code below can only use in ViewController class instead of View class, this Leavesview is handle by a LeavesviewController, and I use this viewController in another PDFViewController to display, so how could I make it jump to another view or dismiss back???
UIViewController *myView = [[UIViewController alloc]init];
[self.navigationController pushViewController:myView animated:YES];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,显然我两个月前才刚刚起步。另外,显然答案是 委托;
Ok, Obviously I am just a starter 2 months ago. Also, obviously the answer is the Delegation;