【发布时间】:2012-04-06 12:34:56
【问题描述】:
我刚刚通过组合单独的 iPhone 和 iPad 项目使我的应用程序具有通用性。一切似乎都正常,但有一个重大错误。
当 iPad 应用程序启动时,它只会显示黑屏(可能是窗口)和状态栏。当我按下主页按钮时,我突然看到 SplitViewController 消失了。当我再次打开应用程序时,会显示 SplitViewController。
我不明白为什么控制器只在我关闭并重新打开应用程序后才显示。有什么想法吗?
(我不知道是什么原因造成的,所以如果您需要来自特定位置的代码示例,请告诉我)。
谢谢。
编辑:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[Appirater appLaunched:YES];
// Registers this class as the delegate of the audio session.
[[AVAudioSession sharedInstance] setDelegate: self];
// Allow the app sound to continue to play when the screen is locked.
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
justOpened = YES;
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
{deleted}
} else {
[self.window addSubview:self.splitViewController.view];
[self.window makeKeyAndVisible];
CGRect rect = CGRectMake(-2, self.window.frame.size.height-29, self.window.frame.size.width+2, 29);
imgBar = [[UIImageView alloc] initWithFrame:rect];
imgBar.contentMode = UIViewContentModeScaleToFill;
imgBar.image = [UIImage imageNamed:@"wood_btm.png"];
imgBar.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleTopMargin;
self.splitViewController.showsMasterInPortrait = YES;
self.splitViewController.title = @"Exams";
self.splitViewController.splitPosition=280;
}
return YES;
}
更新:
通过弄乱窗口的背景颜色,我发现由于某种原因它位于视图层次结构的顶部。然后我使窗口的背景颜色清晰,我可以看到 SplitViewController。奇怪的是,我也可以与之互动。所以基本上我已经通过使窗口清晰来解决这个问题。这显然不是理想的解决方案,所以如果有人能想到原因,请告诉我。
【问题讨论】:
-
@ryudice 不只是标准的 xib。
-
发布您的 -applicationDidFinishLaunching:WithOptions: 方法。
-
@CodaFi 方法我已经贴了(我删除了一些不相关的代码-iPhone代码显然没有被调用所以不需要发布它-)
-
我将添加窗口子视图并使其在 else 块的末尾可见。你能测试一下吗?
-
@fbernardo 谢谢,但我已经尝试过了,得到了相同的结果。
标签: iphone ios ipad viewcontroller universal