2017-10-10 110 views
1

设置消息左对齐我使用UIAlertView中,如下UIAlertView中 - 在IOS

UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Review" message:[dictionary valueForKey:@"Review"] delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
[alert show]; 

Image using default UIAlertView

UIAlertView中使用附件查看

NSMutableString *message = [NSMutableString string]; 
    NSString *title = [dictionary valueForKey:@"REVIEW"]; 
    [message appendString:title]; 
    [message appendString:@"\n"]; 

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Review" message:@"" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; 

    [alert setValue:[self getLabelWithMessage:message withTitle:title] forKey:@"accessoryView"]; 
    [alert show]; 

UIAlertView - using AccessoryView

第二个解决方案工作正常对我来说,按照以下解决方案

Simple UIAlertView with NSAttributedString(s)

但这种解决方案将其批准的苹果?

[alert setValue:[self getLabelWithMessage:message withTitle:title] forKey:@"accessoryView"]; 

我需要在UIAlertView中设置左对齐到消息。

任何其他解决方案的建议。

在此先感谢。

+0

使用alertView子视图的解决方案无法正常工作...! – Vidhyanand

+0

虽然这篇文章是关于几年前,但它似乎是相当新的,所以我觉得糟糕,但'UIAlertView'已被弃用,因为iOS9和['UIAlertController'](https://developer.apple。 com/documentation/uikit/uialertcontroller)是该块上的新成员。 – holex

回答

0

首先,我想强调,因为iOS的9尝试UIAlertView已被弃用,并使用UIAlertController。但是这不符合您定制对齐的目的。

其次,UIAlertView,UIAlertController,0 UIActionSheet被认为是系统控制,这意味着不建议定制它们的外观。我认为这不会影响您的审核过程。但是你永远不知道,苹果评论家有时会接受一些应用程序,并拒绝一些具有相同限制的东西。这就是为什么我们应该坚持准则。