gpt4 book ai didi

ios - 当 ViewController 已经有委托(delegate)时如何设置委托(delegate)?

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:31:36 24 4
gpt4 key购买 nike

我有一个发送电子邮件的 iPhone 应用程序。如果未设置“收件人:”地址,我会显示一个警报 (UIAlertView)。目前,我不检查用户点击确定,我只是继续我的快乐方式! :D

点击警报上的“确定”时出现以下错误:

wait_fences: failed to receive reply: 10004003

我相信这是因为我没有处理 OK 的点击,并且当应用程序正在执行其他操作时它仍然显示。因此,在对 SO 和 Google 进行了一些研究之后,看来我必须拥有这个:

- (void) Alert: (NSString *) title andData: (NSString *) errorMsg  {

UIAlertView *alert = [[UIAlertView alloc]
initWithTitle: title
message: errorMsg
delegate:nil
cancelButtonTitle: @"OK"
otherButtonTitles: nil];
[alert show];


return;

}

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
NSLog(@"button was pressed");
}

我的问题是我不知道如何为此设置委托(delegate)。我已经有一个代表:

@interface ReportViewController : UIViewController <UIWebViewDelegate>  {

如何设置代理以便处理 OK 按钮的点击,从而消除错误?

最佳答案

在尖括号内,您可以提供以逗号分隔的协议(protocol)列表。

@interface ReportViewController : UIViewController <UIWebViewDelegate, UIAlertViewDelegate>  {

现在您可以实现两组方法。并且不要忘记将警报 View 的委托(delegate)设置为 self

关于ios - 当 ViewController 已经有委托(delegate)时如何设置委托(delegate)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13167932/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com