如何让超出父视图区域的子视图实现点击事件 在父视图重写hitTest:withEvent:方法,代码如下:- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { //CGRectMake(50, 50, 100, 100)是相对于该视图而言的 if([selfisLocationInRectWithPoint:point wit
二维码扫描:ZBar,ZXing的使用 原文链接:http://blog.csdn.net/whjblog/article/details/15809859iOS二维码扫描开源库主要有Zbar和ZXing,在完成项目的过程中都用过,开始时用了Zbar,但其相对于ZXing扫描识别效率太低,无法达到项目要求,所以改用ZXing。两个开源库都可以识别二维码,但ZBar还支持条形码,ZXing识别条形码还需要改一些地方。
iOS输入汉字时限制字数 UITextInputMode *inputMode = [[UITextInputMode activeInputModes] firstObject];if([inputMode.primaryLanguage isEqualToString:@"zh-Hans"]){ UITextRange *selectedRange = [_textField markedTextRange];
远程推送 一、生成对应的生产通知证书和发布通知证书证书生成部分就不做介绍了二、开启应用的推送能力 这是会生成一个TestPush.entitlements文件,里面APS Environment属性值为development,直接运行一直是测试环境,打包为ipa后则为正式环境。三、注册远程通知1.导入头文件在Appdelegate.m文件里引入UserNotifications...
自动打包执行命令报错 执行自动打包执行命令报错xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance输入下面命令解决sudo xcode-selec...
XCode生成html测试覆盖率报告 1.首先需要安装HomeBrew 打开命令行输入:ruby -e “$(curl –insecure -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)” 然后按回车键继续,再输入密码继续安装 2.配置xcode,打开测试的buildsettings 然后再build phases中添加一个N
iOS TouchID验证和Keychain结合使用 1.TouchID的简单实现首先先导入LocalAuthentication/LocalAuthentication.h头文件 使用TouchID前先检测TouchID是否可用,然后再调用LAContext *context = [[LAContext alloc] init];BOOL success = [context canEvaluatePolicy:LAPolicyDeviceOwn
iOS自定义转场动画 自定义转场动画主用到3个类实现UIViewControllerAnimatedTransitioning协议的动画类继承UIPercentDrivenInteractiveTransition类的手势类实现UIViewControllerContextTransitioning协议的transitionContext先实现present和dismiss动画PresentedViewContr
Today Extension 1.首先创建一个主体应用程序2.创建Today Extension程序 给你的TodayExtension起一个名字,建好以后会变成下图的文件结构系统默认给你创建了一个storyboard,有好多人喜欢用纯代码开发,没问题,接下来使用去掉storyboard删掉storyboard后打开plist文件,出现下图然后将NSExtensionMainStoryboard删掉,添加NSExtensi
图片剪裁 - (UIImage *)getClipImage:(UIImage *)sourceImage clipRect:(CGRect)clipRect { CGFloat (^rad)(CGFloat) = ^CGFloat(CGFloat deg) { return deg / 180.0f * (CGFloat) M_PI; }; CGAffineTransfo
iOS粒子动画 - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. _fireEmitterLayer = [CAEmitterLayer layer]; //设置发射器位置 _fireEmitterL
iOS让controller具有右滑pop的效果 首先要有navigationcontroller,在navigationcontroller的viewdidload方法里添加下面的代码NSObject *targetObjc = [[self.interactivePopGestureRecognizer valueForKey:@"_targets"] firstObject]; NSObject *target = [targetOb
iOS单元测试中测试异步方法 - (void)testAsync { //设置预期 XCTestExpectation *expactation = [self expectationWithDescription:@"异步测试"]; [Person loadPersonAsync:^(Person *person) { NSLog(@"%@",person); //预期达成
3DTouch 3DTouch是iOS9出的新特性,用户可以在手机主屏幕和app内部使用1. 主屏幕的快捷操作当用户按压应用图标是会弹出快捷操作列表,当用户选择选择一个快捷操作是,应用会被激活或者启动,同事你的代理对象会收到快捷操作的信息。固定的快捷操作:需要在Info.plist里设置 UIApplicationShortcutItems 动态的快捷操作:需要使用UIApplicationShortcutIt
Quartz 2D 1.1 The Graphics Context所有的东西都是画在CGContextRef类型的对象上Quartz 2D中一些数据类型CGPathRef:用于绘画的线CGImageRef:一个矢量图片CGLayerRef:一个绘画层,可以重复绘画和离屏绘画CGPatternRef:用于重复绘画的CGShadingRef和CGFrandientRef:用于渐变绘画CGFunctionRef
iOS富文本和html字符串互转 //html字符串转换为富文本NSString *htmlStr = @"我的aafaf微我的aafaf微"; NSAttributedString *att = [[NSAttributedString alloc] initWithData:[htmlStr da
iOS对图片进行马赛克处理 //获取BitmapData CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGImageRef imageRef = originalImage.CGImage; CGFloat width = CGImageGetWidth(imageRef); CGFloat heigth = CGImag
iOS捕捉图像 iOS媒体捕捉一、捕捉类介绍捕捉会话AVCaptureSessionAV Foundation捕捉栈的核心类是AVCaptureSession,这个类相当与一个插排,用于连接输入和输出资源,捕捉会话还可以额外配置一个会话预设值(session preset)用来控制捕捉数据的格式和质量捕捉设备AVCaptureDeviceAVCaptureDevice为摄像头或麦克风等物理设备定义了一个接口,它
iOS视频转换格式 //需要转换的视频地址NSURL *fileUrl = info[@"UIImagePickerControllerMediaURL"];//转换后的视频地址NSString *output = [NSHomeDirectory() stringByAppendingString:@"/Documents/Movie.mp4"];NSURL *outputUrl = [NSURL fileU
使用AVPlayerViewController播放视频 AVPlayerViewController的属性player:用来播放媒体内容的AVPLayer实例showsPlaybackControls:表示播放控件是否显示或隐藏的布尔类型值videoGravity:播放视频界面的缩放比例readyForDisplay:视频内容是否已经准备好播放NSURL *url = [[NSBundle mainBundle] URLForResource: