摇动以模式方式打开视图
我的“摇动”工作正常(使用motionEnded),基于Apple的GLPaint代码。当用户摇动设备(运行 3.0 及更高版本)时,我想使用presentModalViewController 以模态方式打开视图控制器。
在我的 appdelegate 中,我收到通知(根据 GLPaint 示例代码):
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(shakeToOpenHiddenScreen) name:@"shake" object:nil];
在我的 shakeToOpenHiddenScreen 中,我只想以模态方式打开视图“x”,但我不认为我的 appdelegate 会响应 PresentModalViewController。
有办法解决这个问题吗?
I have my 'shake' working fine (using motionEnded), based off of Apple's GLPaint code. When the user shakes the device (running 3.0 and up) I want to open a view controller modally using presentModalViewController.
In my appdelegate I have the notification (as per the GLPaint sample code):
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(shakeToOpenHiddenScreen) name:@"shake" object:nil];
In my shakeToOpenHiddenScreen I just want to open view 'x' modally but I don't think that my appdelegate will respond to presentModalViewController.
Is there a way around this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要使用presentModalViewController,您必须从UIViewController类或子类中使用它:
例如:
//RootViewController.m
[self.navigationController PresentModalViewController:loginRegView 动画:YES];
您可以通过在应用程序委托中定义导航控制器
并合成它来
解决此问题:要使用presentModalViewController,您必须从 UIViewController 类或子类中使用它:
例如:
您可以通过在应用程序委托中定义导航控制器来解决此问题你的应用程序委托:
合成它
,现在你可以使用该方法:
但是,首先你必须将它分配到某个地方,我将在 RootViewController 中进行它
应该可以工作,让我知道:)
To use presentModalViewController you have to use it from a UIViewController class, or subclass:
For example:
//RootViewController.m
[self.navigationController presentModalViewController:loginRegView animated:YES];
You can way around this problem by defining a navigation controller into your app delegate:
and synthesize it
To use presentModalViewController you have to use it from a UIViewController class, or subclass:
For example:
You can way around this problem by defining a navigation controller into your app delegate:
synthesize it
and now you can use the method:
but, first you have to assign it somewhere, i will do it in the RootViewController
It should work, let me know :)
它是 UIViewController 上的一种方法,因此您应该能够从 appDelegate 访问已保存的视图控制器,或者设置通知来调用一个 (addObserver:someVC)。
“shake”不是标准通知名称,因此应用程序中的其他位置应该有一些代码发布此通知,大概也是从 GLPaint 示例复制的。
It is a method on UIViewController, so you should either have access to a saved view controller from your appDelegate, or else set up the notification to call one (addObserver:someVC).
"shake" isn't a standard notification name, so there should be some code elsewhere in your app that posts this notification, presumably also copied from the GLPaint sample.