你好,歡迎來到IOS教程網

 Ios教程網 >> IOS訊息 >> 關於IOS >> iOS程序內語言切換設計思路

iOS程序內語言切換設計思路

編輯:關於IOS
NSString *loc = @"zh-Hans";
    if (![self isChinese]) {
        loc = @"en";
    }
    NSString *path = [[NSBundle mainBundle] pathForResource:_file
                                                     ofType:@"strings"                                                       
                                                inDirectory:nil
                                            forLocalization:loc];
    
    // compiled .strings file becomes a "binary property list"
    NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:path];
    
    NSString *str = [dict objectForKey:_key];
    if (str) {
        return str;
    }
    return _key;

然後用NSNotificationCenter去實現內容更新

  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved