Three20只是给了黑屏?

时间:2011-03-09 05:19:27

标签: iphone ios-simulator three20

我目前正在使用 Three20(v 1.0.4)构建项目。它构建并运行时没有错误或警告。它只是AppDelegate和TTLauncher类。

AppDelegate.h

#import <Three20/Three20.h>

@interface AppDelegate : NSObject <UIApplicationDelegate>
{
}

@end

AppDelegate.m

#import "AppDelegate.h"
#import "LauncherController.h"

@implementation AppDelegate

//=============================================================
// UIApplicationDelegate

- (void)applicationDidFinishLaunching:(UIApplication*)application
{
    TTNavigator* navigator = [TTNavigator navigator];
    navigator.persistenceMode = TTNavigatorPersistenceModeAll;
    TTURLMap* map = navigator.URLMap;
    [map from:@"*" toViewController:[TTWebController class]];
    [map from:@"tt://launcher" toViewController:[LauncherController class]];
    [navigator openURLAction:[TTURLAction actionWithURLPath:@"tt://launcher"]];
}

- (BOOL)application:(UIApplication*)application handleOpenURL:(NSURL*)URL
{
    [[TTNavigator navigator] openURLAction:[TTURLAction actionWithURLPath:URL.absoluteString]];
    return YES;
}

@end

LauncherController.h

#import <Three20/Three20.h>


@interface LauncherController : TTViewController <TTLauncherViewDelegate> 
{
    TTLauncherView* _launcherView;
}

@end

LauncherController.m

#import "LauncherController.h"


@implementation LauncherController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
    {
        self.title = @"Launcher Screen";
    }
    return self;
}

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

- (void)loadView
{
    [super loadView];

    _launcherView = [[TTLauncherView alloc] initWithFrame:self.view.bounds];
    _launcherView.backgroundColor = [UIColor whiteColor];
    _launcherView.delegate = self;
    _launcherView.columnCount = 2;
    _launcherView.pages =
    [NSArray arrayWithObjects:
     [[[TTLauncherItem alloc] initWithTitle:@"New Position" image:@"bundle://ic_positions2.png" URL:nil] autorelease], nil];
    [self.view addSubview:_launcherView];
}

- (void)launcherView:(TTLauncherView*)launcher didSelectItem:(TTLauncherItem*)item {
}

- (void)launcherViewDidBeginEditing:(TTLauncherView*)launcher {
    [self.navigationItem setRightBarButtonItem:[[[UIBarButtonItem alloc]
                                                 initWithBarButtonSystemItem:UIBarButtonSystemItemDone
                                                 target:_launcherView action:@selector(endEditing)] autorelease] animated:YES];
}

- (void)launcherViewDidEndEditing:(TTLauncherView*)launcher {
    [self.navigationItem setRightBarButtonItem:nil animated:YES];
}

@end

为什么我会得到以下屏幕?

Blank screen, iPhone Simulator

2 个答案:

答案 0 :(得分:6)

请检查您的main.m文件以获取以下行:

int retVal = UIApplicationMain(argc, argv, nil, nil);

您需要将最后一个参数更改为包含应用委托名称的字符串。在你的情况下,你会写:

int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");

答案 1 :(得分:0)

请检查app delegate的主窗口是否可见,并将必要的视图添加到主窗口。

[self.window makeKeyAndVisible];
[self.window addSubview:startingview];