gpt4 book ai didi

ios - 启动画面 iOS 后黑屏

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:27:56 24 4
gpt4 key购买 nike

在做一个高级项目时,我的应用最近开始在启动画面后只加载黑屏。我没有使用 Storyboard。我一直在寻找解决这个问题的方法,但似乎无法使其他解决方案适应我的项目。我的 [github] ( https://github.com/cleif/Hastings/tree/Fixed ) 在这里有最新版本。下面是我的 AppDelegate.h & .m 文件中的代码。

.h

#import <UIKit/UIKit.h>
#import "IIViewDeckController.h"
#import "MenuViewController.h"
#import "HomeViewController.h"
#import "AboutViewController.h"
#import "AthleticsViewController.h"
#import "BroncoBoardViewController.h"
#import "ContactsTableViewController.h"
#import "MapViewController.h"

@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (retain, nonatomic) UIViewController *menuViewController;
@property (retain, nonatomic) UIViewController *rootViewController;

@end

.m

#import "AppDelegate.h"

@implementation AppDelegate

@synthesize menuViewController = _menuViewController;

- (IIViewDeckController*) initializeMainViewControllers {

UIViewController *menuViewController = [[MenuViewController alloc] init];
UIViewController *rootViewController = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil];

IIViewDeckController* deckController = [[IIViewDeckController alloc] initWithCenterViewController:[[UINavigationController alloc] initWithRootViewController:rootViewController]
leftViewController:menuViewController];

return deckController;
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

IIViewDeckController* deckController = [self initializeMainViewControllers];

self.menuViewController = deckController.leftController;
self.rootViewController = deckController.centerController;

self.window.rootViewController = deckController;
[self.window makeKeyAndVisible];

return YES;
}

@end

如有任何建议,我们将不胜感激。

最佳答案

我得到了你的代码并在下面添加了一行 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 现在工作正常

self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]]; 

所以你的 didFinishLaunchingWithOptions 方法必须是这样的

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];

IIViewDeckController* deckController = [self initializeMainViewControllers];

self.menuViewController = deckController.leftController;
self.rootViewController = deckController.centerController;

self.window.rootViewController = deckController;
[self.window makeKeyAndVisible];

return YES;
}

关于ios - 启动画面 iOS 后黑屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24996758/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com