我目前正在使用 Three20(v 1.0.4)构建项目。它构建并运行时没有错误或警告。它只是AppDelegate和TTLauncher类。
#import <Three20/Three20.h>
@interface AppDelegate : NSObject <UIApplicationDelegate>
{
}
@end
#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
#import <Three20/Three20.h>
@interface LauncherController : TTViewController <TTLauncherViewDelegate>
{
TTLauncherView* _launcherView;
}
@end
#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
为什么我会得到以下屏幕?
答案 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];