简体   繁体   English

我收到一条错误消息:“使用未声明的标识符'事件'”

[英]I am getting an error that reads “Use of Undeclared Identifier 'event'”

I am getting an error that reads "Use of Undeclared Identifier 'event'" that appears on this line. 我收到此行上出现的错误消息“使用未声明的标识符'事件'”。 Can someone help? 有人可以帮忙吗?

UIView *senderView = [[event.allTouches anyObject] view];

Here is the code. 这是代码。

  }
  -  (void)didTap_tabBarItem1 {
      CurrentItemsViewController *controller = [[CurrentItemsViewController alloc] init];
      UINavigationController *navigationController = [[UINavigationController alloc]
         initWithRootViewController:controller];
      [navigationController setNavigationBarHidden:YES animated:NO];
      UIView *senderView = [[event.allTouches anyObject] view];
      CGRect senderFrame = [senderView convertRect:senderView.frame toView:self.view];
      self.tabBarItem1Popover = [[[UIPopoverController alloc] initWithContentViewController:navigationController
         ] autorelease];
      [self.tabBarItem1Popover presentPopoverFromRect:senderFrame inView:self.view permittedArrowDirections:
         UIPopoverArrowDirectionAny animated:YES];
      [navigationController release];
      [controller release];
   }

Thanks. 谢谢。

it's all because in you use undeclared variable event. 这是因为您使用了未声明的变量事件。 You don't pass it to your method - (void)didTap_tabBarItem1 . 您不会将其传递给方法- (void)didTap_tabBarItem1 You can do something like this - (void)didTap_tabBarItem1:(UIEvent *)event but you should pass this event variable to this method. 您可以执行以下操作- (void)didTap_tabBarItem1:(UIEvent *)event但应将此event变量传递给此方法。

You don't have any variable named event 您没有任何名为event的变量

Did you copy and paste this code? 您是否复制并粘贴了此代码?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM