1

次のことを実行できる適切なドキュメントが見つからないようです。

iPhoneアプリにJSONで変換されてUITableViewに表示されるUTF-8文字列がたくさんあります。ユーザーがアイテムをクリックすると、UIActionSheetが表示され、選択したカテゴリが通知されます。


代替テキスト


問題は、漢字がUITableViewに問題なく表示されるのに対し、UIActionSheetではUTF-8文字として表示されることです。UTF-8から繁体字中国語の文字に変換する方法はありますか?

私はこのようにしようとしていますが、機能していません:

const char *subCatName = [[thirdParamStringArr objectAtIndex:1] UTF8String];
    NSString *subCatSelectedConverted = [[NSString alloc] initWithUTF8String:subCatName];       

    NSString *actionSheetTitle = [@"You have selected " stringByAppendingString:subCatSelectedConverted];

    NSString *actionSheetTitleFinal = [actionSheetTitle stringByAppendingString:@", proceed to upload to selected subcategory?"];

    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:actionSheetTitleFinal delegate:self cancelButtonTitle:@"Proceed to Upload" destructiveButtonTitle:@"Cancel" otherButtonTitles:nil];

前もって感謝します!

4

1 に答える 1

2

わかりました、さらに調査した後、これはトリックを行いました:

NSString *subCatSelectedName = [[thirdParamStringArr objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];


        NSString *actionSheetTitle = [@"You have selected '" stringByAppendingString:subCatSelectedName];

        NSString *actionSheetTitleFinal = [actionSheetTitle stringByAppendingString:@"', proceed to upload to selected subcategory?"];

        UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:actionSheetTitleFinal delegate:self cancelButtonTitle:@"Proceed to Upload" destructiveButtonTitle:@"Cancel" otherButtonTitles:nil];

これはトリックをしました:


代替テキスト

于 2010-06-29T09:16:27.150 に答える