工作知識庫
因為Louis是個健忘的人~~ 因此將一些SOP步驟放在這裡, 忘了可以來看看囉
2011年11月6日 星期日
2011年10月3日 星期一
UIWebView讀取本地端檔案
1.把要加入專案的檔案(如HTML、CSS等)拖入專案,並選取create folder reference,這樣才會在專案內建立相對路徑。

2.專案Build之前,記得先Clean一下
程式碼部分
//檢查html路徑是否存在
NSFileManager *fileManager = [[NSFileManager alloc] init];
NSString *appPath = [[NSBundle mainBundle] resourcePath];
NSString *htmlPath = [appPath stringByAppendingPathComponent:@"/GS45X/product/outlander"];
//NSLog(@"%@",htmlPath);
if ([fileManager fileExistsAtPath:htmlPath]) { //如果html的路徑存在
//建立webView
UIWebView* WebView = [[UIWebView alloc] initWithFrame:CGRectMake(0.0, 0.0, 768, 1024)];
//建立baseUrl
NSURL *baseURL = [NSURL fileURLWithPath:htmlPath];
//index.html的路徑
NSString *filePath = [htmlPath stringByAppendingPathComponent:@"index.html"];
//NSLog(@"%@",filePath);
NSData *htmlData = [NSData dataWithContentsOfFile:filePath];
if (htmlData) {
[WebView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:baseURL];
}
[self.view addSubview:WebView];
[WebView release];
}
else {
NSLog(@"不存在");
}
[fileManager release];

2.專案Build之前,記得先Clean一下
程式碼部分
//檢查html路徑是否存在
NSFileManager *fileManager = [[NSFileManager alloc] init];
NSString *appPath = [[NSBundle mainBundle] resourcePath];
NSString *htmlPath = [appPath stringByAppendingPathComponent:@"/GS45X/product/outlander"];
//NSLog(@"%@",htmlPath);
if ([fileManager fileExistsAtPath:htmlPath]) { //如果html的路徑存在
//建立webView
UIWebView* WebView = [[UIWebView alloc] initWithFrame:CGRectMake(0.0, 0.0, 768, 1024)];
//建立baseUrl
NSURL *baseURL = [NSURL fileURLWithPath:htmlPath];
//index.html的路徑
NSString *filePath = [htmlPath stringByAppendingPathComponent:@"index.html"];
//NSLog(@"%@",filePath);
NSData *htmlData = [NSData dataWithContentsOfFile:filePath];
if (htmlData) {
[WebView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:baseURL];
}
[self.view addSubview:WebView];
[WebView release];
}
else {
NSLog(@"不存在");
}
[fileManager release];
2011年5月3日 星期二
[iphone]Apple Mach-O Linker Error
2011年2月22日 星期二
2011年1月12日 星期三
[iphone]Screen Capture in UIKit Applications
https://developer.apple.com/library/ios/#qa/qa2010/qa1703.html
2011年1月10日 星期一
2010年12月29日 星期三
[教學] 如何建立軟體的Lite版本
[教學] 如何建立軟體的Lite版本
1.在您專案中的Goups & Files 下找到 Targets
2.在您的軟體名稱如MagicFighter上按下右鍵並選擇Duplicate
3.將複製出來的新Target更名為 xxxLite 如 MagicFighterLite
4.找到Info copy.plist並更名為 InfoLite.plist
5.在左上方的下拉式選單切換您的Active Target為Lite版本如MagicFighterLite
6.在Targets下雙擊您新的Target如MagciFighterLite以開啟 Target Info設定畫面
7.將左上方的Configuration修改為 All configurations
8.確認您在Packaging分類中的Info.plist File欄位設定為InfoLite.plist
9.將Product Name修改為 xxxLite 如MagicFighterLite
10.將上方的Build頁籤切換為Properties
11.修改Icon File:中的資料為您Lite版的Icon名稱如IconLite.png
12.切回Build頁籤並確認以下的步驟是否正確:
12-1 請確認您欲使用的Active SDK版本
12-2 請確認Active Target是設定在您的Lite版本
12-3 Configuration:的設定確認為All Configurations
12-4 在GCC 4.0 - Language的分類下找到 Other C Flags 欄位並加入 -DLITE_VERSION
13.最後,在您的程式中就可以使用類似下列的方式來設定正式版與Lite版的差異功能了
- (void)viewDidLoad {
[super viewDidLoad];
#ifdef LITE_VERSION
[proFeaturesButton setHidden:YES];
[buyFullButton setHidden:NO];
#else
[proFeaturesButton setHidden:NO];
[buyFullButton setHidden:YES];
#endif
}
1.在您專案中的Goups & Files 下找到 Targets
2.在您的軟體名稱如MagicFighter上按下右鍵並選擇Duplicate
3.將複製出來的新Target更名為 xxxLite 如 MagicFighterLite
4.找到Info copy.plist並更名為 InfoLite.plist
5.在左上方的下拉式選單切換您的Active Target為Lite版本如MagicFighterLite
6.在Targets下雙擊您新的Target如MagciFighterLite以開啟 Target Info設定畫面
7.將左上方的Configuration修改為 All configurations
8.確認您在Packaging分類中的Info.plist File欄位設定為InfoLite.plist
9.將Product Name修改為 xxxLite 如MagicFighterLite
10.將上方的Build頁籤切換為Properties
11.修改Icon File:中的資料為您Lite版的Icon名稱如IconLite.png
12.切回Build頁籤並確認以下的步驟是否正確:
12-1 請確認您欲使用的Active SDK版本
12-2 請確認Active Target是設定在您的Lite版本
12-3 Configuration:的設定確認為All Configurations
12-4 在GCC 4.0 - Language的分類下找到 Other C Flags 欄位並加入 -DLITE_VERSION
13.最後,在您的程式中就可以使用類似下列的方式來設定正式版與Lite版的差異功能了
- (void)viewDidLoad {
[super viewDidLoad];
#ifdef LITE_VERSION
[proFeaturesButton setHidden:YES];
[buyFullButton setHidden:NO];
#else
[proFeaturesButton setHidden:NO];
[buyFullButton setHidden:YES];
#endif
}
訂閱:
意見 (Atom)
