2017-10-12 78 views
0

所以我有和自定义UIAlertView应用程序(通过自定义我的意思是在底部以编程方式添加UILabel)。它在iOS < 11上运行得很好,但是在iOS 11中它失败了。因此,在iOS 10上它工作正常(左),但在iOS 11(右)中失败,使用相同的代码当然iOS 10 vs iOS 11iOS 11自定义UIAlertView不呈现罚款

这是我用来制作自定义UAlertView的代码。有任何想法吗?

SessionManager *sessionMgr = [SessionManager sharedManager]; 
NSString *saludoStr = [NSString stringWithFormat:@"¡Bienvenido %@!",self.datosPersonalesResponse.nombre]; 
NSString *mailStr = [sessionMgr getUserEmail]; 
NSString *mensajeStr = [NSString stringWithFormat:@"Te hemos enviado un email de \nactivación de cuenta a: \n\n%@\n\nActivá tu cuenta para recibir alertas,\n avisos recomendados y postularte a \nempleos.\n",mailStr]; 

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:saludoStr message:@"" delegate:self cancelButtonTitle:@"Cerrar" otherButtonTitles:@"No lo recibí", nil]; 
UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; 
lbl.numberOfLines= 0; 

[lbl setFont:[UIFont fontWithName:@"OpenSans" size:13]]; 
[lbl setTextColor:[UIColor colorWithRed:146/255.0f green:146/255.0f blue:146/255.0f alpha:1.0]]; 

NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc] initWithString:mensajeStr]; 
[attributedStr addAttribute:NSFontAttributeName 
         value:[UIFont fontWithName:@"OpenSans-Semibold" size:16] 
         range:NSMakeRange(56,[mailStr length])]; 

[attributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(56,[mailStr length])]; 

lbl.attributedText = attributedStr; 
lbl.textAlignment = NSTextAlignmentCenter; 
[alert setValue:lbl forKey:@"accessoryView"]; 
[alert show]; 
+0

'UIAlertView'从来不支持添加自定义视图的能力。它可能在过去有效,但文档一直声明不这样做。 – rmaddy

回答

2

UIAlertView中已被弃用。请考虑使用UIAlertControllerfull details here

+1

这是评论,而不是答案。 – rmaddy

+0

答案不一定是解决方案,但如果它打扰你,我可以删除它。 – McNight