1
我想在UIAlertview上顯示一些左側和中間對齊的多語句,但是這段代碼對於ios 7工作甚至可以用於ios 8,但是最後一個標籤沒有顯示。AlertView-iOS8中沒有顯示多行語句
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSString *equipmentString [email protected]"100114 Mica Unit 5 and 6";
NSString *projectString [email protected]"01-130156 FORD-FIVEHUNDREDSEL";
NSString *employeeString [email protected]"00167293 Blake Linfield";
NSString *[email protected]"28-Aug-2014";
NSString *[email protected]"Thursday";
NSString *[email protected]"Proceed to inspection?";
UIView *alertContainerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 271, 150)];
UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(10, 5, CGRectGetWidth(alertContainerView.frame) - 20, 20)];
label1.textAlignment = NSTextAlignmentCenter;
label1.font = [UIFont boldSystemFontOfSize:14.0f];
label1.text = title;
[alertContainerView addSubview:label1];
UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(label1.frame) + 2, CGRectGetWidth(alertContainerView.frame) - 20, 20)];
label2.textAlignment = NSTextAlignmentLeft;
label2.font = [UIFont systemFontOfSize:14.0f];
label2.text = equipmentString;
label2.lineBreakMode = NSLineBreakByTruncatingTail;
label2.numberOfLines = 1;
[alertContainerView addSubview:label2];
UILabel *label3 = [[UILabel alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(label2.frame) + 2, CGRectGetWidth(alertContainerView.frame) - 20, 20)];
label3.textAlignment = NSTextAlignmentLeft;
label3.font = [UIFont systemFontOfSize:14.0f];
label3.text = projectString;
label3.lineBreakMode = NSLineBreakByTruncatingTail;
label3.numberOfLines = 1;
[alertContainerView addSubview:label3];
UILabel *label4 = [[UILabel alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(label3.frame) + 2, CGRectGetWidth(alertContainerView.frame) - 20, 20)];
label4.textAlignment = NSTextAlignmentLeft;
label4.font = [UIFont systemFontOfSize:14.0f];
label4.text = employeeString;
label4.lineBreakMode = NSLineBreakByTruncatingTail;
label4.numberOfLines = 1;
[alertContainerView addSubview:label4];
UILabel *label5=[[UILabel alloc]initWithFrame:CGRectMake(10, CGRectGetMaxY(label4.frame)+2, CGRectGetWidth(alertContainerView.frame)-20, 20)];
UIFont* boldFont = [UIFont boldSystemFontOfSize:[UIFont systemFontSize]];
label5.textAlignment = NSTextAlignmentCenter;
label5.font = [UIFont systemFontOfSize:14.0f];
label5.text = lastInspectedDate;
[label5 setFont:boldFont];
label5.lineBreakMode = NSLineBreakByTruncatingTail;
label5.numberOfLines = 1;
[alertContainerView addSubview:label5];
UILabel *label6=[[UILabel alloc]initWithFrame:CGRectMake(10, CGRectGetMaxY(label5.frame)+2, CGRectGetWidth(alertContainerView.frame)-20, 20)];
UIFont* boldFont1 = [UIFont boldSystemFontOfSize:[UIFont systemFontSize]];
label6.textAlignment = NSTextAlignmentCenter;
label6.font = [UIFont systemFontOfSize:14.0f];
label6.text = lastInspectionDay;
[label6 setFont:boldFont1];
label6.lineBreakMode = NSLineBreakByTruncatingTail;
label6.numberOfLines = 1;
[alertContainerView addSubview:label6];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:nil cancelButtonTitle:@"NO" otherButtonTitles:@"YES", nil];
[alertView setValue:alertContainerView forKey:@"accessoryView"];
[alertView show];
}
最後一個標籤沒有顯示在ios 8中,但是相同的代碼與ios 7一起工作,請有人幫我解決問題。
沒有這不會幫助我,因爲這是iOS中8,創建UIAlertView中的公正的方式,但我需要添加多個標籤與UIAlertView中一些調整。 – Nawnit 2014-10-13 14:39:54