首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UITextField没有出现在iOS8中

UITextField没有出现在iOS8中
EN

Stack Overflow用户
提问于 2016-06-16 06:08:45
回答 1查看 118关注 0票数 0

因此,我最近为iOS 6开发了一个可读取PDF的应用程序。它在我的iPhone 3GS上运行良好,但是当我在较新版本的Xcode (最初使用4.5,现在使用6.01)为iOS 8重新编译它时,输入您想要加载的PDF名称的文本字段不再显示它应该加载的位置。

当用户按下打开键时,出现在警告框中的文本字段。

下面是在iOS 6中工作的代码

代码语言:javascript
复制
    alert = [[UIAlertView alloc]initWithTitle:@"Please enter a valid PDF name below:" message:@"(Please add .PDF on the end!) \n \n" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"ok", nil];
    textField = [[UITextField alloc] initWithFrame:CGRectMake(10, 200, 300, 40)];
    [textField setBackgroundColor:[UIColor whiteColor]];
    textField.delegate = nil;
    textField.borderStyle = UITextBorderStyleRoundedRect;
    textField.placeholder = @"PDF name";
    textField.tintColor = [UIColor colorWithRed:98.0/255.0f green:98.0/255.0f blue:98.0/255.0f alpha:1.0];
    textField.keyboardAppearance = UIKeyboardAppearanceAlert; //set up an alert box with a text feild
    [textField becomeFirstResponder];
    [alert addSubview:textField];
    [alert show];
    [alert release];
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-06-16 12:31:36

试着遵循代码!!

代码语言:javascript
复制
    UIAlertController * alertView=   [UIAlertController
                                      alertControllerWithTitle:@"Please enter a valid PDF name below:"
                                      message:@"Please add .PDF on the end!"
                                      preferredStyle:UIAlertControllerStyleAlert];

    [alertView addTextFieldWithConfigurationHandler:^(UITextField *textField) {
        textField.placeholder = @"PDF name";

    }];

    UIAlertAction* yesButton = [UIAlertAction
                                actionWithTitle:@"Ok"
                                style:UIAlertActionStyleDefault
                                handler:^(UIAlertAction * action)
                                {
                                    //Handel your yes please button action here
                                    UITextField *textField = alertView.textFields[0];
                                    NSString *pdfName = textField.text;
                                    NSLog(@"PDF Name: %@",pdfName);
                                    [alertView dismissViewControllerAnimated:YES completion:nil];


                                }];
    UIAlertAction* noButton = [UIAlertAction
                               actionWithTitle:@"Cancel"
                               style:UIAlertActionStyleDefault
                               handler:^(UIAlertAction * action)
                               {
                                   //Handel no, thanks button
                                   [alertView dismissViewControllerAnimated:YES completion:nil];
                               }];

    [alertView addAction:yesButton];
    [alertView addAction:noButton];
    [self presentViewController:alertView animated:YES completion:nil];
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37851151

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档