Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
输入时不显示日期选择器单击iOS 8_Ios_Iphone_Uidatepicker_Uiactionsheet - Fatal编程技术网

输入时不显示日期选择器单击iOS 8

输入时不显示日期选择器单击iOS 8,ios,iphone,uidatepicker,uiactionsheet,Ios,Iphone,Uidatepicker,Uiactionsheet,我在输入字段上显示pickerView,单击它在其他iOS上运行良好,但当我更新到iOS 8时,它不起作用。当我点击输入字段时,它不会显示日期选择器 这是我正在使用的代码 - (void)textFieldDidBeginEditing:(UITextField *)aTextField{ appDelegate.recentAddSowID = @""; if (aTextField == dateTextField) { [dateTextField res

我在输入字段上显示pickerView,单击它在其他iOS上运行良好,但当我更新到iOS 8时,它不起作用。当我点击输入字段时,它不会显示日期选择器

这是我正在使用的代码

- (void)textFieldDidBeginEditing:(UITextField *)aTextField{

     appDelegate.recentAddSowID = @"";

     if (aTextField == dateTextField) {
     [dateTextField resignFirstResponder];

     pickerViewPopup = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"" destructiveButtonTitle:nil otherButtonTitles:nil];

     pickerView = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 44, 0, 0)];
     pickerView.datePickerMode=UIDatePickerModeDate;

     pickerView.hidden = NO;
     pickerView.date = [NSDate date];

     UIToolbar *pickerToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
     pickerToolbar.barStyle = UIBarStyleBlackOpaque;
     [pickerToolbar sizeToFit];

     NSMutableArray *barItems = [[NSMutableArray alloc] init];

      UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
     [barItems addObject:flexSpace];

      UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneButtonPressed:)];
      [barItems addObject:doneBtn];

      UIBarButtonItem *cancelBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonPressed:)];
      [barItems addObject:cancelBtn];

       [pickerToolbar setItems:barItems animated:YES];

       [pickerViewPopup addSubview:pickerToolbar];
       [pickerViewPopup addSubview:pickerView];

       [pickerView addTarget:self action:@selector(updateTextField:) forControlEvents:UIControlEventValueChanged];

       [dateTextField setInputView:pickerView];

       [pickerViewPopup showInView:self.view];
       [pickerViewPopup setBounds:CGRectMake(0,0,320, 464)];
    }
}

我正在测试iPhone 5S。

他们改变了iOS 8中UIActionSheet的实现。您不能再将视图添加到其视图层次结构中

文件规定:

UIActionSheet不是设计成子类的,也不应该将视图添加到其层次结构中。如果您需要提供比UIActionSheet API提供的自定义更多的工作表,您可以创建自己的工作表,并使用presentViewController:animated:completion:以模式显示它

此外,iOS 8中不推荐使用UIActionSheet

重要提示:iOS 8中不推荐使用UIActionSheet。请注意,UIActionSheetDelegate也不推荐使用。要在iOS 8及更高版本中创建和管理操作表,请改用UIAlertController和首选样式UIAlertControllerStyleActionSheet

或者,尝试以下方法:。它适用于iOS 8,可能正是您所需要的


来源:

设置断点。是否调用了该方法?是否检查了设备?对我来说,它不会出现在模拟器中,但在模拟机上运行良好device@Daiji-Djan方法称为它在ios上的模拟器上运行良好7@ShantiK是的,对我来说,它在模拟器上工作,但在设备上不工作,因为模拟器是iOS7,这不是我的意思。如果它不起作用-它被称为。对不起,我想你运气不好。这是升级到iOS 8的痛苦之一: