2012-04-25 10 views
1

私は棒グラフを描画するためにcore-plotを使用しています。私はx軸に日付を表​​示しています。私は次のコードを使用しました:ipad(ios)の日付をフォーマットした後の不明な文字

NSDateFormatter * formatter=[[NSDateFormatter alloc]init]; 
[formatter setDateFormat:@"dd MMM yy"]; 

double tickLocation=0.5; 
NSMutableArray *customLabels = [NSMutableArray arrayWithCapacity:[valuesArray count]]; 
for (HistoryIndividualValueBean * value in valuesArray) 
{ 
    CPTAxisLabel *newLabel = [[CPTAxisLabel alloc] initWithText:[formatter stringFromDate:value.submittedTime] textStyle:x.labelTextStyle]; 
    newLabel.tickLocation = [[NSNumber numberWithDouble:tickLocation++] decimalValue]; 
    newLabel.offset  = x.labelOffset + x.majorTickLength; 
    newLabel.rotation  = M_PI_2; 
    [customLabels addObject:newLabel]; 
    [newLabel release]; 
} 

[formatter release]; 

x.axisLabels = [NSSet setWithArray:customLabels]; 

これは、iPhoneでうまくいきます。しかし、ipad上では、これは私が上にフォーマットした日付で奇妙な文字を表示します。この画像を参照してください:

enter image description here

+3

あなたは中国語または日本語ロケールで実行していますか? '月'は、私が正しく思い出した場合、「月」のシンボルです。 – dasblinkenlight

+0

@dasblinkenlight大変ありがとうございます。私はこれが問題だと思う。実際、クライアントはこのスクリーンショットを送った、私は彼に言う。彼は日本に住んでいるので、これが問題だと思います。再度ありがとう –

答えて

1

あなたはこの動作がMMM形式は、ロケール固有のものであることがわかり理由。日本では、月を月の数字でフォーマットした後、という文字をフォーマットします。

あなたは、ロケールにかかわらず表示されるヶ月の3文字の名前が好きで、あなたのフォーマッタのロケールとして米国を選ぶだろう場合:

NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]; 
[formatter setLocale:usLocale]; 
+0

百万のおかげで、ここでいくつかの人生を救った。 –

関連する問題