3

此代码(人们关注文本框时出现的日期选择器)在 ios6 上非常完美,但在 ios7 上无法单击“完成按钮”:

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

    UIToolbar *pickerDateToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 40)];


    pickerDateToolbar.barStyle = UIBarStyleBlackOpaque;
    [pickerDateToolbar 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(closeText)];
    [barItems addObject:doneBtn];

    [pickerDateToolbar setItems:barItems animated:YES];
     [textField.inputView addSubview:pickerDateToolbar];


}

谢谢

4

0 回答 0