我在尝试在应用程序中显示应用内横幅(状态栏上方)时遇到问题。问题是,当我在文本字段中输入文本时,如果出现横幅,它会移除键盘,然后一旦横幅消失(它在计时器上),键盘就会再次出现。有没有办法在状态栏上方有一个横幅视图,同时如果键盘是第一响应者,键盘不会消失。
InAppNotificationView* _sharedPushView = nil;
NSArray * nibArr = [[NSBundle mainBundle] loadNibNamed: @"InAppNotificationView" owner: self options: nil];
for (id currentObject in nibArr)
{
if ([currentObject isKindOfClass: [InAppNotificationView class]])
{
_sharedPushView = (InAppNotificationView*) currentObject;
break;
}
}
_sharedPushView.delegate = self;
[self.displayedPushViews addObject: _sharedPushView];
_topView.window.windowLevel = UIWindowLevelStatusBar;
[UIView animateWithDuration: 0.25
animations: ^
{
CGPoint centerPoint = _sharedPushView.center;
centerPoint.y += _sharedPushView.frame.size.height;
_sharedPushView.center = centerPoint;
}
completion: nil];
[self.closeTimer invalidate];
self.closeTimer = nil;
self.closeTimer = [NSTimer scheduledTimerWithTimeInterval: 3.0f
target: self
selector: @selector(close)
userInfo: nil
repeats: NO];