Xcode 4 通用窗口应用程序 - 基本查询

发布于 2024-11-26 00:07:27 字数 1245 浏览 0 评论 0原文

我正在努力开始使用 Xcode 4.1 中的通用应用程序模板。我遵循 kotancode 此处 规定的基本原则。问题是如何加载相关的视图控制器。我将重点以 iPhone 部分为例。我创建了一个没有 XIB 的 UIViewController 子类作为我的“主”视图控制器类(共享代码将在其中)。然后我将其子类化以创建名为 BaseViewController_iPhone 的 iPhone 特定 UIViewController 类,这次使用 XIB。

iPhone 特定的应用程序委托标头设置为:

#import "TestAppDelegate.h"
#import "BaseViewController_iPhone.h"

@interface TestAppDelegate_iPhone : TestAppDelegate {
    BaseViewController_iPhone *viewController;
}
@property (nonatomic, retain) IBOutlet BaseViewController_iPhone *viewController;

@end

对于实现,我尝试重写 applicationdidfinishlaunchingwithoptions 方法。

#import "TestAppDelegate_iPhone.h"

@implementation TestAppDelegate_iPhone

@synthesize viewController;

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [self.window addSubview:viewController.view];
    [self.window makeKeyAndVisible];
    return YES;
}

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

@end

这似乎不起作用,它可以正常编译并运行,但不会显示新的视图控制器和相应的 XIB(模板中的原始主窗口 xib 是)。我确信我错过了一些非常简单的东西,但我花了很长时间谷歌搜索却无济于事。非常感谢任何帮助。

谢谢。

I'm struggling getting started with the Universal App template in Xcode 4.1. I'm following the basic principles set out by kotancode here. The problem is getting the relevant view controller to load. I will focus on the iPhone part as an example. I create a subclass of UIViewController without a XIB as my "master" view controller class (where shared code will go). I then subclass this to create the iPhone specific UIViewController class called BaseViewController_iPhone, this time with a XIB.

The iPhone specific app delegate the header is set to:

#import "TestAppDelegate.h"
#import "BaseViewController_iPhone.h"

@interface TestAppDelegate_iPhone : TestAppDelegate {
    BaseViewController_iPhone *viewController;
}
@property (nonatomic, retain) IBOutlet BaseViewController_iPhone *viewController;

@end

and for the implementation I try to override the applicationdidfinishlaunchingwithoptions method.

#import "TestAppDelegate_iPhone.h"

@implementation TestAppDelegate_iPhone

@synthesize viewController;

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [self.window addSubview:viewController.view];
    [self.window makeKeyAndVisible];
    return YES;
}

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

@end

This doesn't appear to work, it compiles fine and runs, but the new view controller and the corresponding XIB are not displayed (the original main window xib from the template is). I'm sure i'm missing something very simple, but i've spent a long time googling to no avail. Any help gratefully received.

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我三岁 2024-12-03 00:07:27
  • 您是否已将应用程序委托的 XIB 中的 ViewController 连接到您的“BaseViewController_iPhone *viewController”?

  • 您确定应用程序委托的 XIB 中的 ViewController 属于 BaseViewController 类型吗?

  • ViewController 是否加载了正确的 XIB(在应用程序的委托的 xib 中检查)?

检查并提供一些反馈。

  • Have you connected the ViewController in the app's delegate's XIB to your "BaseViewController_iPhone *viewController" ?

  • Are you sure the ViewController in the app's delegate's XIB is of the type BaseViewController?

  • Is the ViewController loading the correct XIB (check that in the app's delegate's xib)?

Check that and give some feedback.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文