gpt4 book ai didi

Ios黑屏

转载 作者:行者123 更新时间:2023-11-29 13:49:36 25 4
gpt4 key购买 nike

所以我正在做一个简单的应用程序。我必须 nib 文件。我将首先加载的 nib 从 viewController 更改为 firstController,但它只显示一个空白屏幕。这是我的代码:

MyAppDelegate.h

#import <UIKit/UIKit.h>

@class IpadAppViewController,FirstPageViewController;

@interface IpadAppAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
IpadAppViewController *viewController;
IBOutlet FirstPageViewController *firstController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet IpadAppViewController *viewController;
@property (nonatomic, retain) IBOutlet FirstPageViewController *firstController;

@end

MyAppDelegate.m

//
// IpadAppAppDelegate.m
// IpadApp
//
// Created by Stefan Andrei on 3/24/11.
// Copyright 2011 IMC. All rights reserved.
//

#import "IpadAppAppDelegate.h"
#import "IpadAppViewController.h"
#import "FirstPageViewController.h"

@implementation IpadAppAppDelegate

@synthesize window;
@synthesize viewController;
@synthesize firstController;


#pragma mark -
#pragma mark Application lifecycle

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

// Override point for customization after app launch.
[self.window addSubview:firstController.view];
[self.window makeKeyAndVisible];
return YES;
}


- (void)applicationWillResignActive:(UIApplication *)application {
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
*/
}


- (void)applicationWillTerminate:(UIApplication *)application {
/*
Called when the application is about to terminate.
See also applicationDidEnterBackground:.
*/
}


#pragma mark -
#pragma mark Memory management

- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
/*
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
*/
}


- (void)dealloc {
[viewController release];
[window release];
[super dealloc];
}


@end

最佳答案

在做 [self.window addSubview:firstController.view] 之前,你应该做

self.firstController = [[[FirstPageViewController alloc] initWithNibName:nil bundle:nil] autorelease];

如果您已经创建了 FirstPageViewController 和 .xib,那么这就足够了,否则您可能需要在 initWithNibName 中传递 nib 的名称(没有 .xib 部分):

编辑:添加了 autorelease - firstController 属性已经保留。

关于Ios黑屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5582153/

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