iphone – 这个黑客会让苹果大发雷霆吗? (拒绝我的应用程序吗?)

前端之家收集整理的这篇文章主要介绍了iphone – 这个黑客会让苹果大发雷霆吗? (拒绝我的应用程序吗?)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我从这里获取了这段代码

Changing the background color of a UIAlertView?

UIAlertView *theAlert = [[[UIAlertView alloc] initWithTitle:@"Atention"
   message: @"YOUR MESSAGE HERE",nil)
   delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease];

   [theAlert show];

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

   UILabel *theBody = [theAlert valueForKey:@"_bodyTextLabel"];
   [theBody setTextColor:[UIColor blueColor]];

   UIImage *theImage = [UIImage imageNamed:@"Background.png"];    
   theImage = [theImage stretchableImageWithLeftCapWidth:16 topCapHeight:16];
   CGSize theSize = [theAlert frame].size;

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

   [[theAlert layer] setContents:[theImage CGImage]];

由oxigen发布的.

我不太确定我应该在我的应用程序中使用此代码.苹果会不会有任何关于这个黑客的问题(他们会拒绝这个应用吗?)

解决方法

下划线作为您正在访问的属性的前缀(_titleLabel,_bodyTextLabel)清楚地表明这些是私有属性,不应该被修改. Apple最近开始扫描所有提交的二进制文件以访问私有方法属性,这些值在您的应用程序中自行应该足以让您被拒绝.使用私有API,拒绝或拒绝是绝对不是一个好主意,因为它们通常是私有的,并且可能会因未来的操作系统更新而破坏您的应用程序.

此外,您通过更改警报颜色违反了iPhone Human Interface Guidelines

You can specify the text,the number
of buttons,and the button contents in
an alert,but you can’t customize the
background appearance of the alert
itself.

再次,从iPhone Human Interface Guidelines

Because users are accustomed to the appearance and behavior of these views,it’s important to use them consistently and correctly in your application.

猜你在找的Xcode相关文章