【问题标题】:Cocoa touch : Multiple line text inputCocoa touch : 多行文本输入
【发布时间】:2012-06-05 15:27:26
【问题描述】:

在我的UIViewController <GLKViewDelegate>中选择对象时需要做一个简单的文本输入。

UIKit 中是否有一个简单的多行文本输入弹出窗口可供使用?

我已经找到了UIAlertViewalertViewStyle=UIAlertViewStylePlainTextInput,但这只是一个简单的行输入。

谢谢

【问题讨论】:

    标签: ios cocoa-touch textinput


    【解决方案1】:

    如果您的意思是文本输入 UIAlertViewUITextView 而不是 UITextField 等效,答案是否定的。

    【讨论】:

    • 当然你可以自己滚动,但问题是“UIKit 中是否有一个简单的多行文本输入弹出窗口可供使用”,所以答案是否定的。跨度>
    【解决方案2】:

    你的问题不是很清楚。但我认为UIActionSheet 是您所需要的。

    编辑

    你可以试试这个

    在 un .h 文件中这样设置委托

    @interface NameOfYourClass : UIViewController <UIActionSheetDelegate> 
    

    并将这段代码添加到 un .m 文件中

    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Action Sheet" delegate:self cancelButtonTitle:@"Cancel Button" destructiveButtonTitle:@"Destructive Button" otherButtonTitles:@"Other Button 1", @"Other Button 2", nil];
    
        actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
    
        [actionSheet showInView:self.view];
    

    编辑2

    下面是向您的 allertview 添加文本字段的方法

    UIAlertView *newAlert =[[UIAlertView alloc] initWithTitle:@"ADD item" message:@"Put it blank textfield will cover this" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
    
        UITextField *newTextField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)];
        newTextField.text=@"";
        [newTextField setBackgroundColor:[UIColor whiteColor]];
        [newTextField setKeyboardAppearance:UIKeyboardAppearanceAlert];
        [newTextField setAutocorrectionType:UITextAutocorrectionTypeNo];
    
        [newTextField setTextAlignment:UITextAlignmentCenter];
        [newAlert addSubview:newTextField];
    
        [newAlert show];
    

    【讨论】:

    • 已编辑,您必须在 .h 类中设置 actionSheet 的委托
    • 好吧,我终于知道你需要什么了!拥有更多文本字段的警报视图的唯一方法是在 UIView 的基础上创建自定义警报视图
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多