很抱歉这个模糊的问题,但我不知道如何使它更具体,因为我不知道代码有什么问题。你们可能会立即知道这些错误的含义。
我正在尝试在应用程序启动时显示覆盖图像,然后通过点击手势使覆盖消失。我只是无法让它工作。我从另一个 SO 问题中获得了代码(链接:创建点击覆盖指令视图)。有什么想法我在这里想念的吗?我的代码显示了我收到的错误消息(2 个错误,1 个警告)。
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIImageView *overlay = [[UIImageView alloc]
initWithImage:[UIImage imageNamed:@"overlayImg.png"]];
[self.window addSubview:overlay];
UITapGestureRecognizer * recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
recognizer.delegate = self; //WARNING: Assigning to 'id<UIGestureRecognizerDelegate>'from incompatible type 'AppDelegate *const__strong'
[overlay addGestureRecognizer:recognizer];
overlay.userInteractionEnabled = YES;
self.overlay = overlay; //ERROR: Property 'overlay' not found on object of type 'AppDelegate *'
// Override point for customization after application launch.
return YES;
}
- (void) handleTap:(UITapGestureRecognizer *)recognizer
{
[self.overlay removeFromSuperView]; //ERROR: Property 'overlay' not found on object of type 'AppDelegate *'
}