0

I have a problem. I am developing a game like ludo. In this i have to create text field, for all players participating in game. These players may be in all directions of iPad. And for filling answer in this text field user can use keyboard of iPad. But problem is that I am unable to open keyboard form all sides of iPad.

I am using-

[[UIApplication sharedApplication] setStatusBarOrientation:toInterfaceOrientation animated:YES];

for changing orientation of keyboard. It is working in lower ios versions. But in ios6 it is not working properly. Any help will be appreciated.

4

2 回答 2

0

永远不要总是返回 YES

-(BOOL)shouldAutorotate
{
   return YES;
}

在 AppDelegate 中编写代码

[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"_rotation"];

并像这样更改上述方法

-(BOOL)shouldAutorotate
 {
    return [[NSUserDefaults standardUserDefaults] boolForKey:@"_rotation"];
 }

现在您要在应用程序中更改方向。将 _rotation 的上述标志设置为 NO 并在调用 statusBarOrientation 的方法后再次将其设置为 YES。这是因为 statusBarOrientation 方法只有在 shouldAutorotate 方法返回 NO 时才会起作用。

[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"_rotation"];
[[UIApplication sharedApplication] setStatusBarOrientation:toInterfaceOrientation animated:YES];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"_rotation"];
于 2012-11-03T14:55:29.767 回答
0

你写过ios 6的定位方法吗?并且您是否允许 .info plist 文件中的所有方向?

如果没有,那么它在这里写下来..

-(BOOL)shouldAutorotate
{
   return YES;
}
-(NSInteger)supportedInterfaceOrientations
{
   return UIInterfaceOrientationMaskAll;
}

然后尝试定位您的设备并让我知道它是否工作......!

快乐编码!

于 2012-11-03T07:20:07.097 回答