Translate

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];

2012年12月19日 星期三

Xcode4.2 本地化多國語言Localizable跟AppleLanguages

1.再Supporting Files文件夾點右鍵,New File->iOS->Resource->Strings File取名為Localizable

2.選中Localizable.strings 再回Xcode->View->Utilites->File Inspector,再Localization中點擊+添加語言    比如中文英文日文

3.
Localizable.strings(English)
"test"=test";
Localizable.strings(Chinese)
"test="測試";

4.使用方法
[temp_lab setText:NSLocalizedString(@"test", @"測試用的")];
誇號裡第一個參數是要顯示的內容,與個Localozable.strings中的id對應
第二個參數是對第一個參數的註解,一般可以為空字串

另外也可以用程式取得使用者的語系
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 
NSArray *languages = [defaults objectForKey:@"AppleLanguages"]; 
NSLog(@"%@", languages);

2012年12月7日 星期五

how to call shouldautorotatetointerfaceorientation

這個問題是我一個朋友問我的
覺得有可能需要紀錄下來

朋友的問題是
一開始假設機器是橫的
然後我拖動畫面~把開關設成NO~然後轉機器~這時候到了shouldAutorotateToInterfaceOrientation會因為我的布林值而不去旋轉畫面~但是事實上機器已經被設定成直式了
然後我放開後再去檢查機器的方向~這時候我會查到機器是直的~然後做直的layout~但是機器的畫面卻是橫的
所以畫面就整個不對了

最後結論就是
簡單來說就是怎麼去重新觸發shouldAutorotateToInterfaceOrientation

If you are target iOS 5, you can call

[UIViewController attempRotationToDeviceOrientation

which will can shouldAutorotateToInterfaceDeviceOrientation: with the device's current orientation and will rotate the interface if that method returns YES.

參考
http://stackoverflow.com/questions/9051192/iphone-change-orientation-manually

解決囉