当用户需要收到有关通知的通知时,我的应用会显示下拉通知。我面临的问题是,如果我显示下拉通知,并且后面有广告,则会拦截通知上的触摸。我有一个boolean currentDisplayed,当仍然显示通知时,它是YES。如果currentDisplayed == YES,我想拦截广告上的触摸,而不是以模式显示。我该怎么做呢?谢谢!
此致 Kamran Pirwani
Notification code
+(void)onTap:(UITapGestureRecognizer *)tapGestureRecognizer {
CGPoint point = [tapGestureRecognizer locationInView:tapGestureRecognizer.view];
BOOL dismissTapped = [notificationView.closeNotification.layer.presentationLayer hitTest:point] != nil;
BOOL labelTapped = [notificationView.layer.presentationLayer hitTest:point] != nil;
if (dismissTapped) {
[UIView animateWithDuration:1.0f delay:0.0f options:UIViewAnimationOptionBeginFromCurrentState animations:^{
notificationView.alpha = 0.0f;
//notificationView.frame = CGRectMake(currentFrame.origin.x, -currentFrame.size.height, currentFrame.size.width, currentFrame.size.height);
}completion:nil];
}else if(labelTapped) {
[UIView animateWithDuration:0.7f animations:^{
notificationView.alpha = 0.0f;
}completion:^(BOOL finished){
[tapGestureRecognizer.view removeGestureRecognizer:tapGestureRecognizer];
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:@"announcementTapped" object:nil]];
}];
}
}
答案 0 :(得分:0)
为什么不选择更简单的方法,只在通知显示时设置adView.hidden = YES
?当通知即将被驳回时,只需将hidden
设置回NO
即可。