我的弹出框有自己的“完成”按钮,我想通过触摸此选项来关闭弹出框,但仍然无法弄清楚如何,这是应用程序的捕获
创建代码(在名为 VisitVC 的 rootview 控制器内)
- (IBAction)showStartEndEvent:(id)sender {
if ([[UIDevice currentDevice].model hasPrefix:@"iPhone"])
[self performSegueWithIdentifier:@"viewSceneStartEndEvent" sender:self];
else
{
//iPad Popover Section
if (!startEndEventPopover || !startEndEventPopover.popoverVisible)
{
StartEndEventVC *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"StartEndEventVC"];
controller.FecInicioDateSE = self.fecInicioDateV;
controller.fecFinDateSE = self.fecFinDateV;
navController = [[UINavigationController alloc]initWithRootViewController:controller];
navController.toolbarHidden = FALSE;
startEndEventPopover = [[UIPopoverController alloc] initWithContentViewController:navController];
[startEndEventPopover presentPopoverFromRect:CGRectMake(400, [sender convertPoint:[sender bounds].origin toView:self.view].y, 300, 400) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
else{
[startEndEventPopover dismissPopoverAnimated:YES];
startEndEventPopover = nil;
}
}
}
现在弹出控制器(StartEndEventVC)内的“完成”按钮代码
- (IBAction)saveChanges:(id)sender {
if (fechaInValida) {
[[[UIAlertView alloc]initWithTitle:@"Notificación" message:@"La fecha de inicio debe ser anterior a la fecha de finalización" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
return;
}
[self comparaFechaInicio];
[self.startDateLabel removeObserver:self forKeyPath:@"text"];
[self.endDateLabel removeObserver:self forKeyPath:@"text"];
[CurrentParentViewController setFecFinDateV:self.fecFinDateSE];
[CurrentParentViewController setFecInicioDateV:self.fecInicioDateSE];
if ([[UIDevice currentDevice].model hasPrefix:@"iPhone"])
[self.navigationController popViewControllerAnimated:YES];
else{
[self.navigationController dismissViewControllerAnimated:YES completion:^{}];
}
}
关闭弹出框的代码键在块上:
if ([[UIDevice currentDevice].model hasPrefix:@"iPhone"])
[self.navigationController popViewControllerAnimated:YES];
else{
**[self.navigationController dismissViewControllerAnimated:YES completion:^{}];**
}
但不知道如何,有什么想法吗???