iPhone 加速计和横向模式问题
我在 Accelerometer 委托方法中调用一个函数,如下所示
这是在 ViewControllerX.m 中
-(void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
{
[self methodX];
}
我也在接口方法中调用另一个函数,如下所示
此方法在 ViewControllerY 中
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
[object methodY];
//Here "object" is ViewControllerX.m 's Object,
}
问题是,当我摇动我的 iPhone 时
,调用的是 methodY,而不是 methodX。
谁能告诉我如何处理这个问题?
I am calling a function in Accelerometer delegate method like this
This is in ViewControllerX.m
-(void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
{
[self methodX];
}
i am also calling another function in interface method like this
This method is in ViewControllerY
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
[object methodY];
//Here "object" is ViewControllerX.m 's Object,
}
The problem is, when i shake my iPhone
methodY is calling instead of, methodX.
can any one tell me how to handle this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
应该简单地返回一个 BOOL 值,指示是否支持 interfaceOrientation。来自 UIViewController 文档:
根据我的经验,在此方法内进行任何大量处理不是一个好主意。
should simply return a BOOL value indicating whether or not the interfaceOrientation is supported or not. From the UIViewController documentation:
In my experience, it is not a good idea to any extensive processing inside this method.