箇条書きは、Unicodeコード0x2022で表されます。新しい行に「\n」を使用して、このように機能させることができました。
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle: @"How to use buttons"
message: [NSString stringWithFormat: @"%C line 1.\n %C line 2,\n %C line 3", (unichar) 0x2022, (unichar) 0x2022, (unichar) 0x2022];
delegate: nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
それは弾丸のために働くはずです。
左揃えの場合は、次のようにします。
NSArray *subViewArray = alertView.subviews;
for(int x = 0; x < [subViewArray count]; x++){
//If the current subview is a UILabel...
if([[[subViewArray objectAtIndex:x] class] isSubclassOfClass:[UILabel class]]) {
UILabel *label = [subViewArray objectAtIndex:x];
label.textAlignment = NSTextAlignmentLeft;
}
}
要約すると:
- 新しい行を表示する場合は「\n」。
[NSString stringWithFormat:@"%C Line n", (unichar) 0x2022];
弾丸のために。
- 配置については、アラートビューのサブビューを繰り返し処理し、のサブクラスであるサブビューを特定します
UILabel
。次に、を使用して、ラベルのテキストの配置を左揃えに変更しますlabel.textAlignment = NSTextAlignmentLeft
。
- これをすべて行った後、を呼び出すことができます
[alert show];
。