| | |
| | | using System; |
| | | using Shared.IOS.JLCountryCode; |
| | | using Foundation; |
| | | using System.Collections.Generic; |
| | | |
| | | namespace JLCountrycode |
| | | { |
| | |
| | | Shared.Application.currentVC.NavigationController.PushViewController(mJLCountryCodeController, true); |
| | | |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 选择 |
| | | /// </summary> |
| | | /// <param name="titleStr"></param> |
| | | /// <param name="dic"></param> |
| | | /// <param name="action"></param> |
| | | public void ShowSortSelection(string titleStr, Dictionary<string, List<string>> dic, Action<string> action) |
| | | { |
| | | try |
| | | { |
| | | JLSortSelectionViewController vc = new JLSortSelectionViewController(); |
| | | vc.TitleStr = titleStr; |
| | | vc.SortedNameDict = ConvertToNativeDictionary(dic); |
| | | vc.SortSelectionBlock += (countryName) => |
| | | { |
| | | action?.Invoke(countryName); |
| | | }; |
| | | |
| | | Shared.Application.currentVC.NavigationController.PushViewController(vc, true); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Console.WriteLine(ex.ToString()); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Dictionary 转 iOS原生 NSMutableDictionary |
| | | /// </summary> |
| | | /// <param name="dict"></param> |
| | | /// <returns></returns> |
| | | NSMutableDictionary ConvertToNativeDictionary(Dictionary<string, List<string>> dict) |
| | | { |
| | | NSMutableDictionary newDictionary = new NSMutableDictionary(); |
| | | try |
| | | { |
| | | //var dictDataList = new NSMutableArray(); |
| | | foreach (string key in dict.Keys) |
| | | { |
| | | var value = dict[key]; |
| | | newDictionary.Add(new NSString(key), NSArray.FromObjects(value.ToArray())); |
| | | } |
| | | } |
| | | catch (Exception Ex) |
| | | { |
| | | Console.WriteLine(Ex.ToString()); |
| | | } |
| | | return newDictionary; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | } |