0

我正在编写一个供 iPhone 开发人员使用的库(类似于实现 OpenFeint 的方式),并且我正在尝试创建一个具有关联 XIB 的 ViewController 以便我可以在我的代码中使用

SplashScreenViewController *splashScreenViewController = [[SplashScreenViewController alloc] init];
UIWindow *topApplicationWindow = [self getTopWindow];
[topApplicationWindow addSubview:splashScreenViewController.view];

然而,虽然这适用于简单的控件(UIButtons 等),但我的 SplashScreenViewController 没有显示任何内容。SplashScreenViewController 非常简单:

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>


@interface SplashScreenView : UIViewController {
}

@end

并且实现是空的。在我的 View XIB (SplashScreenView.xib) 中,我尝试将 File's Owner 的类设置为 SplashScreenViewController 这不起作用,然后我尝试了我在 OpenFeint 中看到的方法,即在 IB 中添加一个 View Controller 和将主 UIView 设为其子级,并将其设为 SplashScreenViewController 类。这也不起作用(不显示)。

我想知道是否有人对我可能遗漏的内容有一个好主意,或者是否有人可以推荐一个演练以按照我尝试的方式创建新的 ViewController。

谢谢!

4

2 回答 2

1

尝试两件事:

  1. 调用initWithNibName而不仅仅是 init。也许您正在谈论的 OpenFeint 覆盖了 init 以调用 initWithNibName ,这就是您看不到它的原因。

  2. 将 SplashScreenViewController 设置为您的文件所有者,并将他的视图出口连接到您在 IB 中的视图。

希望能帮助到你。

于 2010-08-21T05:53:17.677 回答
0

而不是[splashScreenViewController alloc],尝试[SplashScreenViewController alloc]。我很惊讶您没有收到编译器警告。

于 2010-08-21T07:41:56.567 回答