如何自定义UIAlertView?苹果会批准吗?

发布于 2024-11-02 10:06:20 字数 148 浏览 9 评论 0原文

我使用自定义 UIAlertViewUITextField 从用户那里获取密码。

我被告知这个自定义视图可能会导致我的应用程序被 Apple 拒绝;这是正确的吗?如果是这样,我的自定义控件的合适替代品是什么?

I am using a custom UIAlertView with UITextField to get password from the user.

I have been told that this custom view may cause my App to get reject by Apple; is that correct? If so, what is the appropriate replacement for my custom control?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

等风也等你 2024-11-09 10:06:21

您可以将文本字段添加到 UIAlertView

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"title" message:@"msg" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
UITextField *txtField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)];
[alertView addSubview:txtField];
[alertView show];
[alertView release];

You can add a textfield to your UIAlertView

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"title" message:@"msg" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
UITextField *txtField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)];
[alertView addSubview:txtField];
[alertView show];
[alertView release];
姐不稀罕 2024-11-09 10:06:21

请参阅我的 博客文章 执行此操作及其完全接受的代码由苹果公司。我在我的一些应用程序中添加了这个,它们都被接受了。所以使用它不用担心!

这是您可以使用的代码:

UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"Your title here!" message:@"this gets covered" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
UITextField *myTextField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)];
[myTextField setBackgroundColor:[UIColor whiteColor]];
[myAlertView addSubview:myTextField];
CGAffineTransform myTransform = CGAffineTransformMakeTranslation(0.0, 130.0);
[myAlertView setTransform:myTransform];
[myAlertView show];
[myAlertView release];

See my blog post of doing this and its perfectly accepted code by apple. I added this in some of my apps and they all got accepted. So use it without fear!!

Here is the code you can use :

UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"Your title here!" message:@"this gets covered" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
UITextField *myTextField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)];
[myTextField setBackgroundColor:[UIColor whiteColor]];
[myAlertView addSubview:myTextField];
CGAffineTransform myTransform = CGAffineTransformMakeTranslation(0.0, 130.0);
[myAlertView setTransform:myTransform];
[myAlertView show];
[myAlertView release];
離殇 2024-11-09 10:06:21

如果您担心被拒绝,您可以随时滚动自己的视图,该视图具有类似于 UIAlertView 的动画。在这里查看这个问题:

如何自定义 iOS 警报视图?

If you're concerned about rejection, you can always roll your own view that has animations similar to a UIAlertView. Check this question out here:

How can I customize an iOS alert view?

迷乱花海 2024-11-09 10:06:21

iOS 5 现在原生支持此功能。查看 UIAlertView 的 alertViewStyle 属性。

iOS 5 now supports this natively. Check out UIAlertView's alertViewStyle property.

随波逐流 2024-11-09 10:06:21

引用类参考

UIAlertView 类旨在按原样使用,而不是
支持子类化。该类的视图层次结构是私有的并且
不得修改。

在我看来,最后一句话是他们不希望开发人员修改视图。

Quoting from the class reference

The UIAlertView class is intended to be used as-is and does not
support subclassing. The view hierarchy for this class is private and
must not be modified.

The last sentence appears to me that they don't want developers modifying the views.

过度放纵 2024-11-09 10:06:21

我认为有更好的方法来解决这个问题。这是代码片段

UIAlertView *passwordAlert = [[UIAlertView alloc]                                       
                              initWithTitle:@"Enter Password" message:@""
                              delegate:self 
                              cancelButtonTitle:nil                    
                              otherButtonTitles:@"Submit", nil];

passwordAlert.alertViewStyle = UIAlertViewStyleSecureTextInput;

(您可以在 prodeveloper 博客中找到相关实现)

但这在 iOS 5.0 及更高版本上运行良好仅有的。请记下它。苹果肯定会批准它。

I think there is a better way to solve this. Here is the code snippet

UIAlertView *passwordAlert = [[UIAlertView alloc]                                       
                              initWithTitle:@"Enter Password" message:@""
                              delegate:self 
                              cancelButtonTitle:nil                    
                              otherButtonTitles:@"Submit", nil];

passwordAlert.alertViewStyle = UIAlertViewStyleSecureTextInput;

(You can find related implementations in prodeveloper blog)

But this works fine on iOS 5.0 and above only. Please make a note of it. And Apple will certainly approve it.

心不设防 2024-11-09 10:06:21

Apple 批准了 UIAlertview 的定制。
从 iOS 5.0 开始,苹果提供了 Alertview 类型来获取凭据输入。

这里我列出了一个自定义的alertview,它可以在旧的ios版本和方向上工作
自定义警报视图

谢谢,

Naveen Shan

Ya Apple approve the customization of UIAlertview.
From iOS 5.0 apple gives alertview type to take credential input.

Here I listed a custom alertview which is able to work on older ios version and orientation
custom alertview

thanks,

Naveen Shan

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文