UIAextField内部的UIAlertView无法在iOS4.1中运行,并且可以在3.0中运行 [英] UITextField inside an UIAlertView not working in iOS4.1 and works in 3.0

查看:84
本文介绍了UIAextField内部的UIAlertView无法在iOS4.1中运行,并且可以在3.0中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在UIAlerView中添加了一个UITextField(将用户添加到列表中,其中包含昵称,并且警报视图会询问昵称。)。这在iOS3中完美运行,但是我无法在iOS4.1中键入UITextField。在iOS4.1中,我确实专注于alertview内的文本字段,并且键盘出现,但输入不起作用。

I have a UITextField added to an UIAlerView (Kind of adding user to list with nick name, and nickname is asked by the alertview.). Thats work perfect in iOS3, But I cant type to that UITextField in iOS4.1. in iOS4.1 I do get focus to that textfield inside alertview, and keyboard appears, however typing doesn't work.

请帮助解决这个问题。

推荐答案

在iOS 4中,UIAlertViews将自动移动并调整大小以避免键盘,如果它们在子视图中包含任何UITextFields,那么您不必自己动手吧。只需添加如下文本字段:

In iOS 4 UIAlertViews will automatically be moved and sized to avoid the keyboard if they contain any UITextFields in their subviews so you don't have to move it yourself. Simply add a text field like so:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Hello"
                                                message:@"Tap below to enter text:\n\n"
                                               delegate:nil
                                      cancelButtonTitle:@"Dismiss"
                                      otherButtonTitles:nil];
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(12, 68, 260, 30)];
[textField setBorderStyle:UITextBorderStyleRoundedRect];
[alert addSubview:textField];
[textField release];
[alert show];
[alert release];

一定要添加\ n来为文字字段腾出空间,你必须要玩将球场放在正确的位置。

Be sure to add \n's to make room for your text field, you'll have to play around with getting the field in the correct position.

这篇关于UIAextField内部的UIAlertView无法在iOS4.1中运行,并且可以在3.0中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆