2017-10-10 115 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被認爲是系統控制,這意味着不建議定製它們的外觀。我認爲這不會影響您的審覈過程。但是你永遠不知道,蘋果評論家有時會接受一些應用程序,並拒絕一些具有相同限制的東西。這就是爲什麼我們應該堅持準則。