Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios TextAlign在UIAlertView中不工作?_Ios_Objective C_Iphone_Uialertview_Text Alignment - Fatal编程技术网

Ios TextAlign在UIAlertView中不工作?

Ios TextAlign在UIAlertView中不工作?,ios,objective-c,iphone,uialertview,text-alignment,Ios,Objective C,Iphone,Uialertview,Text Alignment,我想在UIAlertView中对齐我的消息文本,这是我的代码,但当我运行此代码时,文本显示与以前一样,在for循环之后没有任何更改。我还想增加我的文字?我现在正在使用这个代码 UIAlertView *alret = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"%@",[title objectAtIndex:indexPath.row]] message:[NSString st

我想在UIAlertView中对齐我的消息文本,这是我的代码,但当我运行此代码时,文本显示与以前一样,在for循环之后没有任何更改。我还想增加我的文字?我现在正在使用这个代码

UIAlertView *alret = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"%@",[title objectAtIndex:indexPath.row]]
                message:[NSString stringWithFormat:@"%@",[description objectAtIndex:indexPath.row]]
                delegate:nil
                cancelButtonTitle:@"OK"
                otherButtonTitles:nil];
for(id subview in alret.subviews) {
    if([subview isKindOfClass:[UITextView class]]) {
        [(UITextView *)subview setTextAlignment:NSTextAlignmentJustified];       
    }
}
[alret show];
试试这个

for (UIView *view in alert.subviews) {
    if([[view class] isSubclassOfClass:[UILabel class]]) {
        ((UILabel*)view).textAlignment = NSTextAlignmentLeft;
    }
}
希望能有帮助