Ios ipad应用程序wierd行为
我的ipad项目是基于主细节视图的。详细视图的工具栏上有一个按钮,当用户点击该按钮时,它会弹出一个弹出视图,显示四个按钮(作为菜单)。三个按钮的动作如下(三个按钮显示三个不同的模型表单): 另一个按钮的操作是显示MFMailComposeViewController。代码如下所示:Ios ipad应用程序wierd行为,ios,ipad,Ios,Ipad,我的ipad项目是基于主细节视图的。详细视图的工具栏上有一个按钮,当用户点击该按钮时,它会弹出一个弹出视图,显示四个按钮(作为菜单)。三个按钮的动作如下(三个按钮显示三个不同的模型表单): 另一个按钮的操作是显示MFMailComposeViewController。代码如下所示: - (void) emailCurrentGame { NSLog(@"email current game"); MFMailComposeViewController *picker = [[MF
- (void) emailCurrentGame
{
NSLog(@"email current game");
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[self presentModalViewController:picker animated:YES];
picker = nil;
}
奇怪的行为是,当我点击按钮时,应该执行showOnlineSgf(),但实际上执行了emailCurrentGame()。当我在showOnlineSgf()中设置断点时,它会被命中,并且一步一步地执行showOnlineSgf()中的每条语句。但屏幕上显示的结果是MFMainComposeViewController出现
我知道这个问题很难回答。欢迎提出任何建议。检查触发
showOnlineSgf
的ui按钮的插座连接。最有可能的情况是,您在Interface Builder中复制粘贴的ui按钮
,从而使其也复制指定的操作。然后您连接了另一个操作,导致您的ui按钮有两个操作
要解决此问题,只需从emailCurrentGame
操作中断开触发showOnlineSgf
的UIButton
。听起来像是复制粘贴在界面生成器中的已连接按钮。检查按钮是否分配了多个操作。@BorisProhaska和zeiteisen感谢您的评论。它解决了问题。我从未意识到一个事件可能会连接到多个iAction。zeiteisen说的是事实,我复制粘贴了IB中的一个按钮,这导致按钮有两个连接。你们两个可以移动你们的评论来回答,然后我可以投票给你们。我也会接受鲍里斯的回答,因为它比另一个早了一分钟。
- (void) emailCurrentGame
{
NSLog(@"email current game");
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[self presentModalViewController:picker animated:YES];
picker = nil;
}