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"]];
}
}
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白屏
原来是uiwebview 进化到wkwebview 原因是uiwebview内存消耗比较高 使用wkwebview内存更低
原理是wkwebview把加载和渲染放在两个进程里 白屏大概率是因为渲染进程因为内存等原因被干掉
监测白屏
在webview加载完的时间点 快照 再监测webview中的像素点 如果全白 在一定时间后重新reload
xcodebuild -create-xcframework -framework XXX.framework -output XXX.xcframework
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuide API_AVAILABLE(ios(11.0),tvos(11.0));
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideTop API_AVAILABLE(ios(11.0),tvos(11.0));
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideBottom API_AVAILABLE(ios(11.0),tvos(11.0));
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideLeft API_AVAILABLE(ios(11.0),tvos(11.0));
@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideRight API_AVAILABLE(ios(11.0),tvos(11.0));
#pragma - 将saveBase64编码中的"-","_"字符串转换成"+","/",字符串长度余4倍的位补"="
+(NSData*)safeUrlBase64Decode:(NSString*)safeUrlbase64Str
{
// '-' -> '+'
// '_' -> '/'
// 不足4倍长度,补'='
NSMutableString * base64Str = [[NSMutableString alloc]initWithString:safeUrlbase64Str];
base64Str = (NSMutableString * )[base64Str stringByReplacingOccurrencesOfString:@"-" withString:@"+"];
base64Str = (NSMutableString * )[base64Str stringByReplacingOccurrencesOfString:@"_" withString:@"/"];
NSInteger mod4 = base64Str.length % 4;
if(mod4 > 0)
[base64Str appendString:[@"====" substringToIndex:(4-mod4)]];
NSLog(@"Base64原文:%@", base64Str);
return [GTMBase64 decodeData:[base64Str dataUsingEncoding:NSUTF8StringEncoding]];
}
#pragma - 因为Base64编码中包含有+,/,=这些不安全的URL字符串,所以要进行换字符
+(NSString*)safeUrlBase64Encode:(NSData*)data
{
// '+' -> '-'
// '/' -> '_'
// '=' -> ''
NSString * base64Str = [GTMBase64 stringByEncodingData:data];
NSMutableString * safeBase64Str = [[NSMutableString alloc]initWithString:base64Str];
safeBase64Str = (NSMutableString * )[safeBase64Str stringByReplacingOccurrencesOfString:@"+" withString:@"-"];
safeBase64Str = (NSMutableString * )[safeBase64Str stringByReplacingOccurrencesOfString:@"/" withString:@"_"];
safeBase64Str = (NSMutableString * )[safeBase64Str stringByReplacingOccurrencesOfString:@"=" withString:@""];
NSLog(@"safeBase64编码:%@", safeBase64Str);
return safeBase64Str;
}
我正在编写一个包含C扩展的gem。通常当我写一个gem时,我会遵循TDD的过程,我会写一个失败的规范,然后处理代码直到它通过,等等......在“ext/mygem/mygem.c”中我的C扩展和在gemspec的“扩展”中配置的有效extconf.rb,如何运行我的规范并仍然加载我的C扩展?当我更改C代码时,我需要采取哪些步骤来重新编译代码?这可能是个愚蠢的问题,但是从我的gem的开发源代码树中输入“bundleinstall”不会构建任何native扩展。当我手动运行rubyext/mygem/extconf.rb时,我确实得到了一个Makefile(在整个项目的根目录中),然后当
我已经在Sinatra上创建了应用程序,它代表了一个简单的API。我想在生产和开发上进行部署。我想在部署时选择,是开发还是生产,一些方法的逻辑应该改变,这取决于部署类型。是否有任何想法,如何完成以及解决此问题的一些示例。例子:我有代码get'/api/test'doreturn"Itisdev"end但是在部署到生产环境之后我想在运行/api/test之后看到ItisPROD如何实现? 最佳答案 根据SinatraDocumentation:EnvironmentscanbesetthroughtheRACK_ENVenvironm
这里有一个很好的答案解释了如何在Ruby中下载文件而不将其加载到内存中:https://stackoverflow.com/a/29743394/4852737require'open-uri'download=open('http://example.com/image.png')IO.copy_stream(download,'~/image.png')我如何验证下载文件的IO.copy_stream调用是否真的成功——这意味着下载的文件与我打算下载的文件完全相同,而不是下载一半的损坏文件?documentation说IO.copy_stream返回它复制的字节数,但是当我还没有下
我们的git存储库中目前有一个Gemfile。但是,有一个gem我只在我的环境中本地使用(我的团队不使用它)。为了使用它,我必须将它添加到我们的Gemfile中,但每次我checkout到我们的master/dev主分支时,由于与跟踪的gemfile冲突,我必须删除它。我想要的是类似Gemfile.local的东西,它将继承从Gemfile导入的gems,但也允许在那里导入新的gems以供使用只有我的机器。此文件将在.gitignore中被忽略。这可能吗? 最佳答案 设置BUNDLE_GEMFILE环境变量:BUNDLE_GEMFI
这似乎非常适得其反,因为太多的gem会在window上破裂。我一直在处理很多mysql和ruby-mysqlgem问题(gem本身发生段错误,一个名为UnixSocket的类显然在Windows机器上不能正常工作,等等)。我只是在浪费时间吗?我应该转向不同的脚本语言吗? 最佳答案 我在Windows上使用Ruby的经验很少,但是当我开始使用Ruby时,我是在Windows上,我的总体印象是它不是Windows原生系统。因此,在主要使用Windows多年之后,开始使用Ruby促使我切换回原来的系统Unix,这次是Linux。Rub
我正在尝试解析一个文本文件,该文件每行包含可变数量的单词和数字,如下所示:foo4.500bar3.001.33foobar如何读取由空格而不是换行符分隔的文件?有什么方法可以设置File("file.txt").foreach方法以使用空格而不是换行符作为分隔符? 最佳答案 接受的答案将slurp文件,这可能是大文本文件的问题。更好的解决方案是IO.foreach.它是惯用的,将按字符流式传输文件:File.foreach(filename,""){|string|putsstring}包含“thisisanexample”结果的
我正在玩HTML5视频并且在ERB中有以下片段:mp4视频从在我的开发环境中运行的服务器很好地流式传输到chrome。然而firefox显示带有海报图像的视频播放器,但带有一个大X。问题似乎是mongrel不确定ogv扩展的mime类型,并且只返回text/plain,如curl所示:$curl-Ihttp://0.0.0.0:3000/pr6.ogvHTTP/1.1200OKConnection:closeDate:Mon,19Apr201012:33:50GMTLast-Modified:Sun,18Apr201012:46:07GMTContent-Type:text/plain
无论您是想搭建桌面端、WEB端或者移动端APP应用,HOOPSPlatform组件都可以为您提供弹性的3D集成架构,同时,由工业领域3D技术专家组成的HOOPS技术团队也能为您提供技术支持服务。如果您的客户期望有一种在多个平台(桌面/WEB/APP,而且某些客户端是“瘦”客户端)快速、方便地将数据接入到3D应用系统的解决方案,并且当访问数据时,在各个平台上的性能和用户体验保持一致,HOOPSPlatform将帮助您完成。利用HOOPSPlatform,您可以开发在任何环境下的3D基础应用架构。HOOPSPlatform可以帮您打造3D创新型产品,HOOPSSDK包含的技术有:快速且准确的CAD
在应用开发中,有时候我们需要获取系统的设备信息,用于数据上报和行为分析。那在鸿蒙系统中,我们应该怎么去获取设备的系统信息呢,比如说获取手机的系统版本号、手机的制造商、手机型号等数据。1、获取方式这里分为两种情况,一种是设备信息的获取,一种是系统信息的获取。1.1、获取设备信息获取设备信息,鸿蒙的SDK包为我们提供了DeviceInfo类,通过该类的一些静态方法,可以获取设备信息,DeviceInfo类的包路径为:ohos.system.DeviceInfo.具体的方法如下:ModifierandTypeMethodDescriptionstatic StringgetAbiList()Obt
1.错误信息:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:requestcanceledwhilewaitingforconnection(Client.Timeoutexceededwhileawaitingheaders)或者:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:TLShandshaketimeout2.报错原因:docker使用的镜像网址默认为国外,下载容易超时,需要修改成国内镜像地址(首先阿里