0

目前我的错误说我的视图控制器已经呈现空值。我认为我对下面的代码有正确的想法,但我没有正确实现它。谢谢你的帮助

  -(IBAction)datePicker
{
    //UIViewController *presenter = self.presentingViewController;

    [self dismissViewControllerAnimated:YES completion:^{
        /*
        UIStoryboard*  sb = [UIStoryboard storyboardWithName:@"MainStoryboard.storyboard"
                                                      bundle:nil];
        UIViewController* dateView = [sb instantiateViewControllerWithIdentifier:@"DatePickerViewController"];

         */

        [self performSegueWithIdentifier:@"dueDateSegue" sender:self];
        //[presenter presentViewController:dateView animated:YES completion:nil];

        /*
        [self presentViewController:dateView animated:YES completion:^{

            UIBarButtonItem *saveDate = [[UIBarButtonItem alloc]
                                         initWithTitle:@"Save Date"
                                         style:UIBarButtonItemStyleDone
                                         target:self
                                         action:@selector(labelDatePicker)];
            self.navigationItem.rightBarButtonItem = saveDate;
            pick = [[UIDatePicker alloc] init];
            [pick setFrame:CGRectMake(0,200,320,120)];
            //[pick addTarget:self action:@selector(done) forControlEvents:UIControlEventValueChanged];
            //dateFieldText.delegate = self;
            //dateFieldText.inputView = pick;

        }];
         */

    }];

}
4

1 回答 1

0

在方法中datePicker添加以下行作为第一行代码:

UIViewController *presenter = self.presentingViewController;

然后代替:

 [self presentViewController:dateView animated:YES completion:nil];

尝试使用:

 [presenter presentViewController:dateView animated:YES completion:nil];
于 2013-03-16T19:22:30.563 回答