5
A
回答
1
使可用的國家的陣列,並且在這些delgate方法和數據源的方法
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
使用這個數組 - 在陣列
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
的指數>返回值陣列中元素的數量
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
return 1;
1
您可以從以下就像拿countries.plist和使用烏拉圭回合選擇器輸入
http://code.google.com/p/reviewscraper/source/browse/trunk/Countries.plist?spec=svn22&r=22
20
這裏有一個國家的plist,我爲此創建:
https://gist.github.com/vilcsak/c205dfd153a3e465f47e
實施應該是相當簡單的,但這裏有一些我們的代碼:
- (id)init {
if ((self = [super init])) {
self.countries = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Countries" ofType:@"plist"]];
}
return self;
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
self.currentCountry = [[self.countries objectAtIndex:row] objectForKey:@"code"];
self.countryLabel.text = [[self.countries objectAtIndex:row] objectForKey:@"name"];
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
return self.countries.count;
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
return [[self.countries objectAtIndex:row] objectForKey:@"name"];
}
3
你可以得到可用的國家的名單如下:
self.countryArray = [NSMutableArray new];
for (NSString *countryCode in [NSLocale ISOCountryCodes]) {
NSString *country = [[NSLocale systemLocale] displayNameForKey:NSLocaleCountryCode value:countryCode];
[self.countryArray addObject: country];
}
這裏有一些UIPicker委託方法:
0
這裏是關於國家列表數據選擇器鏈接到博客文章一個popover。 http://iosblogl.blogspot.in/2015/11/pickerview-popover-with-country-list.html
相關問題
- 1. 名單的國家成爲uipickerview SWIFT 3
- 2. IOS&Objective C - 如何用一系列國家填充UIPickerView?
- 3. windows azure在我的國家不可用
- 4. 每個國家的排序國家
- 5. 在Android中獲取國家的國家
- 6. 可用國家/地區列表
- 7. 獲取Facebook用戶國家可能?
- 8. 的Twitter:Twitter4j用戶的國家
- 9. 轉換國家代碼國家名稱
- 10. 選擇國家和國家代碼?
- 11. PHP國際國家代碼2國家代碼的字符
- 12. 標準化的美國國家陣列和國家陣列
- 13. 使用Google API獲取城市的國家/國家建議
- 14. 獲取用戶的國家
- 15. 獲得一個國家的國家當一個國家被選中
- 16. 與ObjectStateEntry的國家
- 17. 獲得美國國家
- 18. 把國旗放在國家
- 19. 英國國家語料庫
- 20. 過度使用國家國旗照片
- 21. 國家和國家撥號代碼,國家名稱和國家圖標目標c
- 22. IPV6到國家
- 23. Crunchbase國家
- 24. 按國家
- 25. 國家顏色
- 26. 國家在TabStackNavigator?
- 27. 按國家
- 28. 使用國家名稱amcharts爲特定國家上色
- 29. 使用Javascript - 填寫國家代碼下拉國家下拉
- 30. Cakephp:用戶模型與國家/國家dropdowm
請分享代碼? – alecnash 2012-12-14 09:50:03