0

I have two tableviews, let´s say one and two, and one presents two when a textfield is tapped, and for this i have:

-(void) setProducts:(UITextField *) box
{
UIViewController *selectInBox = [self.storyboard instantiateViewControllerWithIdentifier:@"selectingProducts"];
popover = [[UIPopoverController alloc] initWithContentViewController:selectInBox];
[popover presentPopoverFromRect:box.bounds inView:box permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}

-(BOOL)textFieldShouldBeginEditing:(UITextField *) textField
{
if (textField.tag == 2)
{
    [self setProducts:textField];

}

Everything works great until know, table "two" appears inside the popover and underneath the textfield, but table "two" has a cancel button that it is supposed to dismiss tableview "two"(inside tableview "one"). So i went to my cancel method in tableview "two" and i did this but it isn´t working and i don't think it can be simple has this:

- (IBAction)cancel:(id)sender
{
[self removeFromParentViewController];
}

I also tried:

- (IBAction)cancel:(id)sender
{
 one *aux = [[one alloc]init];
 [aux.popover dismissPopoverAnimated:YES] //popover is a property of tableview one.  
}

also tried: "if self isBeingPresented"...and nothing is working!.

Any ideas? help!

thanks in advance

4

1 回答 1

0

我已经非常成功地使用了以表单形式(模态)呈现的“弹出框”。

- (IBAction)cancelButtonTapped:(id)sender
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

dismissPopoverAnimated:YES... 应该从呈现视图控制器调用。

于 2013-01-09T11:04:42.280 回答