Translate

2013年2月18日 星期一

xcode 4.6 不能實機測試


xcode給我的錯誤訊息
file is universal (3 slices) but does not contain a(n) armv7s slice: /Users/Sundance/Downloads/FBShareSDK3/FacebookSDK.framework/FacebookSDK for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)

後來解決方法
專案的TARGETS的Build Settings修改
Valid Architectures的值
預設為armv7 armv7s
改成armv7 armv6
就可以安裝到實機上了

2013年2月4日 星期一

NSURL is (null)

有次在做client跟server的溝通使用ASIHTTPRequest做資料傳輸
卻發現
什麼都沒作用直接
- (void)requestFailed:(ASIHTTPRequest *)request
還跑去叫server的人來看php為什麼資料會吐不出來
也跑了error的錯誤來看
Error Error Domain=ASIHTTPRequestErrorDomain Code=5 "Unable to create request (bad url?)" UserInfo=0x8b599e0 {NSLocalizedDescription=Unable to create request (bad url?)}
後來仔細檢測
發現再
NSString to NSURL這邊出了問題而且很奇怪的是
一個中文字不會出現這樣的問題真是妙了

NSString *url_str = [NSString stringWithFormat:@"%@%@&Keyword=%@", area_cate_poi_str, AppDelegate.lag_id, searchbar.text]; NSLog(@"getPoiServer url_str is %@", url_str); NSURL *url = [NSURL URLWithString:url_str]; NSLog(@"url is %@", url); ASIHTTPRequest *request_poi = [ASIHTTPRequest requestWithURL:url]; [request_poi setDelegate:self]; [request_poi startAsynchronous];
2013-02-04 17:10:26.634 Tainan[17738:207] getPoiServer url_str is http://202.3.189.133/tainan/API/poi.php?type=title&lang_id=1&Keyword=台南 2013-02-04 17:10:26.634 Tainan[17738:207] url is (null)
後來發現NSString to NSURL會發生這樣的狀況 才知道是本身語法的問題跟sever沒關係 後來才知道要先幫NSString轉成UTF8格式
NSString *url_str = [NSString stringWithFormat:@"%@%@&Keyword=%@", area_cate_poi_str, AppDelegate.lag_id, searchbar.text]; url_str = [url_str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSURL *url = [NSURL URLWithString:url_str]; NSLog(@"url url_str is %@", url); ASIHTTPRequest *request_poi = [ASIHTTPRequest requestWithURL:url]; [request_poi setDelegate:self]; [request_poi startAsynchronous];
2013-02-04 17:20:40.530 Tainan[17772:207] getPoiServer url_str is http://202.3.189.133/tainan/API/poi.php?type=title&lang_id=1&Keyword=台南 2013-02-04 17:20:40.530 Tainan[17772:207] url is http://202.3.189.133/tainan/API/poi.php?type=title&lang_id=1&Keyword=%E5%8F%B0%E5%8D%97

Ad Hoc利用html安裝

http://esrimobile.blogspot.tw/2012/10/making-release-build-for-ad-hoc.html

http://mobiledevelopertips.com/xcode/distribute-ad-hoc-applications-over-the-air-ota.html

http://aaronparecki.com/articles/2011/01/21/1/how-to-distribute-your-ios-apps-over-the-air

重點再

note: in my case I am using an Microsoft server and I had to add the corresponding MIME Types for the .ipa and .plist. (no screen shots, sorry)

  1. Go to IIS Manager
  2. Locate you web site folder
  3. Right click and select Properties
  4. Open HTTP Headers tab
  5. Click on MIME Types button at the bottom
  6. Click New... button and add these two
    1. .ipa application/octet-stream
    2. .plist text/xml

Now, on your device, navigate to the page and download and install the app.

2013年1月9日 星期三

UILabel auto size

我找過很多資料
發現大部份都是用比較複雜的方法去取得text的長度
再去幫UILabel從新設定尺寸大小
但是其實只需要關鍵的兩行代碼
就可以完成那些複雜的算式

UILabel *temp_lab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 20)];
[temp_lab setText:@"ddddddddddddddddddddddddddddddddddddddddddddddddddd"];

//重點
[temp_lab setNumberOfLines:0];
[temp_lab sizeToFit];

2013年1月1日 星期二

NSFileModificationDate


NSDate *modificationDate = [[fileManager attributesOfItemAtPath:filename(檔案完整路徑) error:nil] objectForKey:NSFileModificationDate];

2012年12月26日 星期三

Init NSIndexPath

NSIndexPath *temp_IndexPath = [NSIndexPath indexPathForRow:lastIndexPath_row inSection:lastIndexPath_section]; 
其中lastIndexPath_row, lastIndexPath_section.形態為NSInteger 
主要是為了讓UITableView做edit有彈跳視窗所使用的

2012年12月20日 星期四

navigationBar setBackgroundImage


[naVC.navigationBar setBackgroundImage:[UIImage imageNamed:@"menubar.png"] forBarMetrics:UIBarMetricsDefault];