0

我打电话给:

emailDetailView.navigationItem.leftBarButtonItem =
    [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
                                                  target:self 
                                                  action:@selector(cancel)];

emailDetailView.navigationItem.rightBarButtonItem =
    [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
                                                  target:self
                                                  action:@selector(emailAddressSelected:emailAddressReturned:)];

UINavigationController *emailDetailNavCon = [[UINavigationController alloc] initWithRootViewController:emailDetailView];

[self presentModalViewController:emailDetailNavCon animated:YES] ;

这是我选择的方法引用:

-(void) emailAddressSelected:(NSString *)emailAddressSelectedString {
    NSLog(@"emailAddressSelected is %@", emailAddressSelectedString);
    emailAddressReturned = emailAddressSelectedString;
    [self performSelector:@selector(showMailComposeController)];
}

-(void)cancel {
    [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:1] 
                                          animated:YES];
}

从子视图上的按钮(取消或完成)回调都没有达到我的预期。

我试图弄清楚如何单击子模式视图取消按钮关闭模式视图并显示父视图。

我还试图弄清楚如何在子模式视图中单击“完成”按钮来执行该emailAddressSelected:(NSString *)emailAddressSelectedString方法。

现在对该emailAddressSelected:(NSString *)emailAddressSelectedString方法的调用正在生成“无法识别的选择器发送到实例”错误。

我已经尝试了以前问题的许多变体,但仍然得到错误或没有得到我期望的按钮操作。

任何帮助,将不胜感激。

4

1 回答 1

0

不确定您的取消选择器有什么问题,但您的完成选择器不正确。应该

@selector(emailAddressSelected:)

但它不会将 NSString 传递给您那里的方法。它将传递发送者,在您的情况下是 UIBarButtonItem。

所以应该是

    -(void) emailAddressSelected:(UIBarButtonItem * )sender
于 2012-09-29T03:59:30.653 回答