1. 共享倒计时结束后自动消失。
iOS 12及以下。
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(getSysBroadcastPickerStandaloneViewController:) name:@"ShowRPBroadcastPickerStandaloneViewControllerNofi" object:nil];
//实现监听方法
-(void)getSysBroadcastPickerStandaloneViewController:(NSNotification *)notification
{
UIViewController *vc = notification.userInfo[@"viewController"];
if (vc) {
self.systemBroadcastPickerViewController = vc;
}
}
if (self.systemBroadcastPickerViewController) {
[self.systemBroadcastPickerViewController dismissViewControllerAnimated:YES completion:nil];
}
//
// UIViewController+DismissBroadcast.m
// TangClient
//
// Created by chip on 2021/7/27.
// Copyright © 2021 QS. All rights reserved.
//
#import "UIViewController+DismissBroadcast.h"
@implementation UIViewController (DismissBroadcast)
+ (void)load
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
[self swizzleSelector:@selector(presentViewController:animated:completion:) withAnotherSelector:@selector(mna_presentViewController:animated:completion:)];
});
}
+ (void)swizzleSelector:(SEL)originalSelector withAnotherSelector:(SEL)swizzledSelector
{
Class aClass = [self class];
Method originalMethod = class_getInstanceMethod(aClass, originalSelector);
Method swizzledMethod = class_getInstanceMethod(aClass, swizzledSelector);
BOOL didAddMethod =
class_addMethod(aClass,
originalSelector,
method_getImplementation(swizzledMethod),
method_getTypeEncoding(swizzledMethod));
if (didAddMethod) {
class_replaceMethod(aClass,
swizzledSelector,
method_getImplementation(originalMethod),
method_getTypeEncoding(originalMethod));
} else {
method_exchangeImplementations(originalMethod, swizzledMethod);
}
}
#pragma mark - Method Swizzling
- (void)mna_presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion
{
if ([NSStringFromClass(viewControllerToPresent.class) isEqualToString:@"RPBroadcastPickerStandaloneViewController"]) {
NSDictionary *dict = @{@"viewController":viewControllerToPresent};
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:@"ShowRPBroadcastPickerStandaloneViewControllerNofi" object:nil userInfo:dict]];
[self mna_presentViewController:viewControllerToPresent animated:flag completion:completion];
} else {
/**
MEETINGQA-21063
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modal view controller on itself. Presenting controller is <GNTSearchController: 0x10995c600>.
*/
if (self != viewControllerToPresent) {
[self mna_presentViewController:viewControllerToPresent animated:flag completion:completion];
}
}
}
@end
iOS13及以上。
//共享成功后调用。
[weakSelf.presenter backToHost];
- (void)backToHost {
if(@available(iOS 10.0, *)) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"quanshiHost://com.quanshi"] options:@{
} completionHandler:nil];
}else{
[[UIApplication sharedApplication] openURL: [NSURL URLWithString:@"quanshiHost://com.quanshi"]];
}
}
2.framework中有同名文件导致iskindofclass失效
p/x
可以打印内存地址
使用分类实现类系统方法,可以小范围实现类似交换方法。
- (BOOL)lc_isKindOfClass:(Class)aClass
{
// 0.参数为NULL,直接给结果
if (aClass == NULL) {
return NO;
}
BOOL value = [self isKindOfClass:aClass];
// 1.系统方法已经断定类型
if (value) {
return YES;
}
NSBundle *objBundle = [NSBundle bundleForClass:self.class];
NSBundle *clsBundle = [NSBundle bundleForClass:aClass];
// 2.对象的类和类属于同一个bundle
if (objBundle == clsBundle || [objBundle.bundlePath isEqualToString:clsBundle.bundlePath]) {
return value;
}
// 3.二者来自于不同的bundle,根据名称补刀
Class objCls = self.class;
NSString *objClsName = nil;
NSString *clsName = NSStringFromClass(aClass);
do {
objClsName = NSStringFromClass(objCls);
value = [objClsName isEqualToString:clsName];
if (value) {
return YES;
}
objCls = class_getSuperclass(objCls);
} while (objCls != NULL);
return NO;
}
调试
连接手机。
device and simulars
open console
筛选关键词 项目名
webview白屏
webview白屏
原来是uiwebview 进化到wkwebview 原因是uiwebview内存消耗比较高 使用wkwebview内存更低
原理是wkwebview把加载和渲染放在两个进程里 白屏大概率是因为渲染进程因为内存等原因被干掉
监测白屏
在webview加载完的时间点 快照 再监测webview中的像素点 如果全白 在一定时间后重新reload
网友评论