UIAlertView *alert = [[UIAlertViewalloc]initWithTitle:self.version message:versionConnet delegate:self cancelButtonTitle:@"取消"otherButtonTitles:@"更新",nil];
UILabel *label = [alert.subviews objectAtIndex:1];
label.textAlignment = UITextAlignmentLeft;
[alert show];
以上方法导致在ios7中直接挂了。
建议程序采用以下写法,虽然在ios7中这样也不能改变,但对程序的兼容性和容错性提高了很多
//message居左对齐
NSArray *subViewArray = alert.subviews;
for(int x=0;x<[subViewArray count];x++){
if([[[subViewArray objectAtIndex:x] class] isSubclassOfClass:[UILabel class]])
{
UILabel *label = [subViewArray objectAtIndex:x];
label.textAlignment = UITextAlignmentLeft;
}
}
ios7的解决方法:https://github.com/wimagguc/ios-custom-alertview