Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/115.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone appDelegate中的触摸事件_Iphone_Ios_Uiview_Uigesturerecognizer_Appdelegate - Fatal编程技术网

Iphone appDelegate中的触摸事件

Iphone appDelegate中的触摸事件,iphone,ios,uiview,uigesturerecognizer,appdelegate,Iphone,Ios,Uiview,Uigesturerecognizer,Appdelegate,这是我的问题 我已经在我的应用程序中实现了推送通知,它工作得很好 应用程序会收到一条消息 在AppDelegories中捕获:DidReceivereMotenofication 创建新的UIView以显示接收到新消息 我唯一的问题是,我希望用户能够点击消息,以便应用程序将打开消息viewcontroller。但我似乎不知道如何捕捉这种触摸,然后在appDelegate中对其进行处理。我在方法中有一个NSLog,它应该打开新的viewcontroller,但似乎从未调用过它 任何帮助都将不胜

这是我的问题

我已经在我的应用程序中实现了推送通知,它工作得很好

  • 应用程序会收到一条消息
  • 在AppDelegories中捕获:DidReceivereMotenofication
  • 创建新的UIView以显示接收到新消息
我唯一的问题是,我希望用户能够点击消息,以便应用程序将打开消息viewcontroller。但我似乎不知道如何捕捉这种触摸,然后在appDelegate中对其进行处理。我在方法中有一个NSLog,它应该打开新的viewcontroller,但似乎从未调用过它

任何帮助都将不胜感激

以下是代码,它位于DidReceiveMemotentification方法中:

    UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotoMessages)];
    UIView *messageView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 45)];
    messageView.userInteractionEnabled = YES;
    messageView.backgroundColor = [UIColor darkGrayColor];
    [messageView addGestureRecognizer:recognizer];
    [self.window addSubview:messageView];

谢谢

我建议您不要为此使用app delegate类。这不是它的目的,它会导致混乱的设计

为什么不使用常规视图控制器和UIView子类?它们是手势和触摸输入的自然场所

至于您的NSLog没有出现的原因,显示该代码可能也会有所帮助

您的点击手势识别器似乎配置为允许在屏幕上的任何位置点击,而不是如您所述在消息上点击。仅供参考