2011-04-26 182 views

回答

2

沒有方法爲AlertView設置背景圖像。我們需要將圖像設置爲警報視圖的子視圖。

嘗試這種方式,將工作:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Message 1......\nMessage 2......" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; 

UIImageView *Image =[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ImageName"]]; 
[alert addSubview:Image]; 

[Image release]; 

[alert show]; 
[alert release]; 
+0

的有關消息1 .... \ n和消息2 .... \ n如果我想顯示消息1和?來自2個變量的消息2? – 2011-04-26 06:42:33

+0

對不起,我不明白你在說什麼? :( – Anand 2011-04-26 08:53:49

+0

noproblem ..我做了一個方法...我想顯示每條消息在不同line.just「\ n」爲我工作......感謝您的幫助 – 2011-04-26 16:21:35

0
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"title" message:@"Empty data not Allowed" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil]; 



    UIImage *alertImage = [UIImage imageNamed:@"custom-dialog-background.png"]; 

    UIImageView *backgroundImageView = [[UIImageView alloc] initWithImage:alertImage]; 

    backgroundImageView.frame = CGRectMake(0, 0, 282, 130); 

    backgroundImageView.contentMode = UIViewContentModeScaleToFill; 

    [alert addSubview:backgroundImageView]; 

    [alert sendSubviewToBack:backgroundImageView]; 


    [alert show];