1
A
回答
3
假設你有那是你的同步過程中設置,在初始視圖控制器initWithNibNamed您的應用程序委託一個屬性:方法檢查由應用程序代理同步的值,並加載適當筆尖通過調用[super initWithNibNamed:@"thisNibInsteadOfThatNib"];
編輯:顯示代碼以啓動取決於一些條件,在發射
// AppDelegate.h
#import <UIKit/UIKit.h>
@interface AppDelegate : NSObject <UIApplicationDelegate>
{
UIWindow *window;
UIViewController *firstViewController;
}
@property {nonatomic, retain} UIWindow *window;
@end
// AppDelegate.m
#import AppDelegate.h
#import ViewControllerOne.h
#import ViewControllerTwo.h
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
BOOL shouldLoadViewOne = \\ some value from preferences
if (shouldLoadViewOne) {
firstViewController = [[ViewOneController alloc] initWithNibName:@"ViewOneController" bundle:nil];
} else {
firstViewController = [[ViewTwoController alloc] initWithNibName:@"ViewTwoController" bundle:nil];
}
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:firstViewController];
[window addSubView:[navController view]];
[window makeKeyAndVisible];
return YES;
}
EDIT 2的不同視圖:
使用NSClassFromSting()
並保存要在首選項中加載的firstViewController的名稱。
// AppDelegate.h
#import <UIKit/UIKit.h>
@interface AppDelegate : NSObject <UIApplicationDelegate>
{
UIWindow *window;
id firstViewController;
}
@property {nonatomic, retain} UIWindow *window;
- (NSString *)firstViewControllerName;
@end
// AppDelegate.m
#import AppDelegate.h
#import ViewControllerOne.h
#import ViewControllerTwo.h
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSString *viewControllerName = [self firstViewControllerName];
firstViewController = [[NSClassFromString(viewControllerName) alloc] initWithNibName:viewControllerName bundle:nil];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:firstViewController];
[window addSubView:[navController view]];
[window makeKeyAndVisible];
return YES;
}
- (NSString *)firstViewControllerName
{
NSString *defaultViewController = @"ViewOneController";
NSString *savedFirstViewController = // string retrieved from preferences or other persistent store
if (!savedFirstViewController)
return defaultViewController;
return savedFirstViewController;
}
相關問題
- 1. 根據應用程序模式加載首選項
- 2. 初始化QuartzScheduler當容器首次加載Web應用程序
- 3. VSTO應用程序加載項不會加載 - 說「管理加載項加載程序無法初始化」
- 4. MVC - 根據用戶加載不同的視圖或加載相同的視圖?
- 5. 僅加載應用程序啓動時的初始視圖和數據
- 6. 初始化首選項
- 7. 首選的應用程序初始化方式
- 8. 基於拆分視圖的應用程序的初始視圖
- 9. 在@Property上加載首選項時,應用程序崩潰(EXC_BAD_ACCESS)
- 10. Android:自動啓動應用程序和加載首選項
- 11. Grails 2應用程序的初始數據加載
- 12. 在iPhone應用程序中加載初始數據的想法?
- 13. 刪除不同應用程序之間的插件首選項
- 14. 不同應用程序之間的Android共享首選項
- 15. 如何爲flex應用程序選擇初始視圖?
- 16. 如何測量加載時間RCP應用程序中的初始透視圖?
- 17. 決定應用程序完成加載前的初始視圖控制器
- 18. 通用應用程序加載不同視圖
- 19. Asp.Net應用程序在初始加載時緩慢加載
- 20. Android中的應用程序首選項
- 21. 如何在每次啓動應用程序時加載初始視圖?
- 22. MVVM根據組合框選擇的項目加載視圖
- 23. 在應用程序代理中運行不同的初始視圖控制器
- 24. 在iphone應用程序加載視圖後加載數據
- 25. XCode選項卡式應用程序不會加載圖標
- 26. Java Applets無法加載; 「開始:應用程序未初始化」
- 27. 刪除應用程序後的應用程序首選項
- 28. 根據瀏覽器語言首選項應用不同的樣式
- 29. Android共享首選項初始化
- 30. iOS應用程序首選項備份
可替代地,如果有用於每個筆尖不同視圖控制器(ViewOneController,ViewTwoController)初始化,你需要基於從同步在'的applicationDidFinishLaunching條件加載控制器或視圖:當然此的 – falconcreek 2010-06-04 13:20:26
'假設這不是一個「國際化」問題,如果您按照Apple文檔創建必要的nib文件,在運行時會自動處理這個問題 – falconcreek 2010-06-04 13:24:08
您可以詳細說明初始化'didFinishLaunchingWithOptions:'嗎? – Brandon 2010-06-04 14:24:06