Ios iphone中未显示UIAlertview的定制?

Ios iphone中未显示UIAlertview的定制?,ios,uialertview,Ios,Uialertview,我在iphone中有一个应用程序,我正在使用下面的代码定制我的alertview。它在模拟器中运行良好。但是当我将它添加到我的iphone时,它显示的是同一个蓝色的。不是我的自定义视图。有人能帮我吗 UIAlertView *theAlert = [[UIAlertView alloc] initWithTitle:@"title" message:@"canceled" delegat

我在iphone中有一个应用程序,我正在使用下面的代码定制我的alertview。它在模拟器中运行良好。但是当我将它添加到我的iphone时,它显示的是同一个蓝色的。不是我的自定义视图。有人能帮我吗

UIAlertView *theAlert = [[UIAlertView alloc] initWithTitle:@"title" message:@"canceled"
                                                       delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
//[alert setUIColor:[UIColor brownColor]]; 
/*[alert show];
[alert release];*/

//UIAlertView *theAlert = [[UIAlertView alloc] initWithTitle:@"Message" message:@"canceled"
                                                       //delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];

[theAlert show];

UILabel *theTitle = [theAlert valueForKey:@"_titleLabel"];
[theTitle setTextColor:[UIColor whiteColor]];

UILabel *theBody = [theAlert valueForKey:@"_bodyTextLabel"];
[theBody setTextColor:[UIColor whiteColor]];
theBody.font = [UIFont boldSystemFontOfSize:16.0];
UIImage *theImage = [UIImage imageNamed:@"pop_up.png"];    
theImage = [theImage stretchableImageWithLeftCapWidth:28 topCapHeight:28];
CGSize theSize = [theAlert frame].size;

UIGraphicsBeginImageContext(theSize);    
[theImage drawInRect:CGRectMake(0, 0, theSize.width, theSize.height)];    
theImage = UIGraphicsGetImageFromCurrentImageContext();    
UIGraphicsEndImageContext();

//[[theAlert layer] setContents:[theImage CGImage]];
[[theAlert layer] setContents:(id)[theImage CGImage]];
[theAlert release];

这是一段关于同一话题的老对话,可以帮助你。

我建议您不要自定义它,因为在未来版本中,您可能会遇到兼容性问题。 如果您强烈需要使用另一个AlertView,请创建一个新的AlertView,如果不是,为什么不使用本机的AlertView呢。万一它不能正常工作,不要担心它们会在下一个版本中出现