View Code? Open in Web Editor
NEW
Just 1 line:Show a banner the same as iOS 9~13 Notification, or show a custom view. 只需一行代码:展示跟 iOS 系统一样的推送通知横幅,或展示一个自定义的 view。支持横屏、自动适应各种机型、自动声音/震动。
License: MIT License
Ruby 9.39%
Objective-C 47.30%
Swift 43.30%
ebbannerview's Introduction
Focusing on iOS Development
🔨 Creator of applications and frameworks
🗣️ Learning the Japanese language now
🗾 East Blue. I came, therefore I see.
ebbannerview's People
ebbannerview's Issues
EBBannerView更新到1.1.2版本, 在应用内收到推送,过几秒种就仍然会崩溃,
从图片左边的调用栈看,一直调用
-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
直至崩溃
EBBannerView.xib:-1: Failed to find or create execution context for description '<IBCocoaTouchPlatformToolDescription: 0x7fbbb197dc20> System content for IBCocoaTouchFramework-NineOneAndLater <IBScaleFactorDeviceTypeDescription: 0x7fbbb1990920> scaleFactor=2x'. These intermediate objects were non-nil: (
我在demo里的SystemStyleViewController.m文件的viewDidLoad方法中加入下列代码
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
将状态条文字改为白色,在显示提示框后状态条文字颜色被修改为黑色
content 内容太粗, 字体太大.
我目前不会写ios 所以不能提pr sorry
可否暴露一个支持横竖屏的方法,出现弹窗后页面状态栏就会滑动,但是需求不能滑
sharedWindow.m里面
[EBBannerViewController setSupportedInterfaceOrientations:UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscape];
默认横竖屏都支持
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/eagle/Library/Developer/CoreSimulator/Devices/07D4020A-3F02-4401-8F6C-7CBE2F9CB6FB/data/Containers/Bundle/Application/66A18A55-B7B2-4483-9530-B03C9746EB2F/demo.app> (loaded)' with name 'EBBannerViewController''
I am not able to read contents when my phone is in dark mode
+(instancetype)bannerViewWithStyle:(EBBannerViewStyle)style{ __block EBBannerView *bannerView; [sharedBannerViews enumerateObjectsUsingBlock:^(EBBannerView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if (obj.maker.style == style) { bannerView = obj; } }]; if (bannerView == nil) { bannerView = [[NSBundle bundleForClass:self.class] loadNibNamed:@"EBBannerView" owner:nil options:nil][style-9]; [[NSNotificationCenter defaultCenter] addObserver:bannerView selector:@selector(applicationDidChangeStatusBarOrientationNotification) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil]; [bannerView addGestureRecognizer]; [sharedBannerViews addObject:bannerView]; } return bannerView; }
12 -9 崩溃
在有UIAlertView弹出后,因为UIEmptywindow的alertLevel为2000,keyWindow会被替换为emptyWindow,这会导致项目中有[UIApplication sharedApplication].keywindow addsubView:xxView];的控件被添加到emptyWindow上,以至于这些控件无法交换和销毁。
onClickNotification 这个属性应该设置为open的访问权限吧,外部无法访问
1、点击推送栏回调不友好(应该返回userinfo,由外部自己处理),不然通过 NSNotification 里拿到的只是 content,一点用也没有,谁也不会拿着 content 去做跳转的。那我也不想在弹出推送栏之前先使用成员变量把跳转进行保存,因为很有可能被后面来的推送给覆盖掉。
2、应该要支持下,当多个推送来时要怎么处理,是pendding住后面的推送还是忽略后面的推送。
3、既然iOS 10已经支持了,如果可以话可以把iOS10的部分封装到你的框架内部,这点你可以自己考虑是否合适,可能封装的工作量会增大很多。
我在demo里的SystemStyleViewController.m文件的viewDidLoad方法中加入下列代码
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
将状态条文字改为白色,在显示提示框后状态条文字颜色被修改为黑色
上个版本还可以
[EBForeNotification handleRemoteNotification:userInfo soundID:1312]; 直接userInfo
现在
EBBannerView *banner = [EBBannerView bannerWithBlock:^(EBBannerViewMaker *make) {
make.style = EBBannerViewStyleiOS9;//指定系统样式,不指定自动依据系统显示不同样式
make.style = 9;//展示 iOS9 样式
make.content = @"MINE eye hath played the painter and hath stelled";
}];
怎么办啊
if (@available(iOS 13.0, *)) {
NSEnumerator *frontToBackWindows = [UIApplication.sharedApplication.windows reverseObjectEnumerator];
for (UIWindow *window in frontToBackWindows) {
BOOL windowOnMainScreen = window.screen == UIScreen.mainScreen;
BOOL windowIsVisible = !window.hidden && window.alpha > 0;
BOOL windowLevelNormal = window.windowLevel == UIWindowLevelNormal;
if (windowOnMainScreen && windowIsVisible && windowLevelNormal) {
return [window hitTest:point withEvent:event];
break;
}
}
// return [UIApplication.sharedApplication.keyWindow hitTest:point withEvent:event];
}
这样取最上层window而不是直接拿keyWindow.
WEAK_SELF(weakSelf); CGFloat originHeight = self.contentLabel.frame.size.height; [UIView animateWithDuration:_maker.animationDuration animations:^{ weakSelf.frame = CGRectMake(weakSelf.fixedX, weakSelf.fixedY, weakSelf.fixedWidth, weakSelf.standardHeight + weakSelf.calculatedHeight - originHeight + 1); } completion:^(BOOL finished) { weakSelf.frame = CGRectMake(weakSelf.fixedX, weakSelf.fixedY, weakSelf.fixedWidth, weakSelf.standardHeight + weakSelf.calculatedHeight - originHeight + 1); }];
楼主你好,看到这里你写的weakSelf我想问下,为什么用weakSelf,这里应该并不具有循环强引用
估计还是keywindow被替换的原因,这一块急需优化,涉及到与keywindow相关的功能都会出现问题
你好,试以下方法,都无法清除通知栏显示的通知;
UIApplication.shared.cancelAllLocalNotifications()
也无法获取通知;
let locals = UIApplication.shared.scheduledLocalNotifications
// 使用代码
// 清除代码
使用了最新版本,选择了custom style后,点击top,出现顶部banner。
再点击banner上的close按钮后,页面变得没有反应,应该是window的问题,还需要修改一下。
最近更新了xocde13 发现无法显示了 目前使用1.1.0版本,通过调试时发现keyWindow是没有大小的,目前我改变了下源码,暂时解决了显示问题
+(instancetype)sharedWindow{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedWindow = [UIApplication sharedApplication].delegate.window;
return sharedWindow;
}
项目中用到的功能不多目前解决了我的问题
同时非常感谢作者!!!
ios13中,本来当前viewController的状态栏是设为白色的(UIStatusBarStyleLightContent),弹出banner后会变回黑色。
点击bannerView时,有时点击方法能够重复三次以上,怎么忽略其他的点击事件呢,
SEGV_ACCERR EBBannerWindow hitTest:withEvent:
是这样,加上你的代码后,keywindow获取到的不是系统的keywindow了,而是你的sharewindow,怎么解决
原因,在pods中的xib不是属于mainbundle的
修改:
EBBannerView.m 46行
NSBundle *bundle = [NSBundle bundleForClass:self.class];
EBBannerViewController.m 19行
NSBundle *bundle = [NSBundle bundleForClass:self.class];
可以解决
如果ios8系统加入此工程,推送的内容多行时,UI会有些错位
建议修改下计算行高的逻辑
文档中说,当手机为静音时,自动切换为震动,但是实际上提示声还是响起了。
手机型号iphone X,系统IOS11.2。
Analyzing dependencies
[!] Unable to find a specification for EBBannerView