-
iOS系统生成二维码
// 1. 创建一个二维码滤镜实例(CIFilter) CIFilter *filter = [CIFilter filterWithName:@"CIQRCodeGenerator"]; // 滤镜恢复默认设置 [filter setDefaults]; // 2. 给滤镜添加数据 NSString *string = @"594589850445580904903"; NSData *data = [string dataUsingEncoding:...…
-
NSURLSession内存泄漏
检查代码是否有leak的时候,发现NSURLSession存在leak,最后发现必须session请求完成后,立即释放,代码如下:- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error{ [session finishTasksAndInvalidate];}…
-
WKWebView 白屏问题
1、WKWebView 自诩拥有更快的加载速度,更低的内存占用,但实际上 WKWebView 是一个多进程组件,Network Loading 以及 UI Rendering 在其它进程中执行。初次适配 WKWebView 的时候,我们也惊讶于打开 WKWebView 后,App 进程内存消耗反而大幅下降,但是仔细观察会发现,Other Process 的内存占用会增加。在一些用 webGL 渲染的复杂页面,使用 WKWebView 总体的内存占用(App Process Memory +...…
-
iOS动画-定时对UIView进行翻转和抖动
(翻转)方式一:[NSTimer scheduledTimerWithTimeInterval:3.f repeats:YES block:^(NSTimer * _Nonnull timer) { CABasicAnimation* rotationAnimation = [CABasicAnimation animation];; rotationAnimation = [CABasicAnimation animationWithKeyPa...…
-
CocoaPods升级
前提是你以前已经安装过CocoaPods 1、查看当前pod版本pod --version2、命令行安装// 先更新gemsudo gem update --system // 需要漫长的等待3、依次执行命令brew install rubygem sources --remove https://rubygems.org/gem sources -a https://ruby.taobao.org/gem sources -l*** CURRENT SOURCES ***https...…
-
iOS判断运营商类型
一、获取运营类型1、需要导入两个头文件#import <CoreTelephony/CTCarrier.h>#import <CoreTelephony/CTTelephonyNetworkInfo.h>2、判断类型// 获取运营商类型+ (SSOperatorsType)getOperatorsType{ CTTelephonyNetworkInfo *telephonyInfo = [[CTTelephonyNetworkInfo alloc] init]...…
-
iOS获取当前网络环境
// 获取网络环境的方法+ (NSString *)networktype{ NSArray *subviews = [[[[UIApplication sharedApplication] valueForKey:@"statusBar"] valueForKey:@"foregroundView"]subviews]; NSNumber *dataNetworkItemView = nil; for (id subview in subviews) { ...…
-
AFN挂代理访问
AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] initWithBaseURL:@"" sessionConfiguration:[self setProxyWithConfig]]; [manager.requestSerializer setValue:@"MQQBrowser" forHTTPHeaderField:@"User-Agent"]; [manager.responseSerializ...…
-
AFN拦截重定向设置httpBody
1、拦截重定向获取里面的cookieAFHTTPRequestOperation *requestOperation=[[AFHTTPRequestOperation alloc] initWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@""]]]; [requestOperation setRedirectResponseBlock:^NSURLRequest *(NSURLConnection *con...…
-
清除WKWebView cookies
在UIWebView下,可以使用[[NSURLCache sharedURLCache] removeAllCachedResponses];//清除缓存 WKWebView清除cookies的方法(iOS9以上)WKWebsiteDataStore *dateStore = [WKWebsiteDataStore defaultDataStore]; [dateStore fetchDataRecordsOfTypes:[WKWebsiteDataStore allWebsit...…
-
解决iOS10不能跳转系统WiFi列表的问题
第一种方式:在iOS10更新后,系统设置跳转被禁用,只能跳转App设置,但是最近发现苹果又更新了URLscheme,亲测可用,建议iOS10已下,还用原来的scheme#define iOS10 ([[UIDevice currentDevice].systemVersion doubleValue] >= 10.0)NSString * urlString = @"App-Prefs:root=WIFI";if ([[UIApplication sharedApplication]...…
-
UITextField添加点击高亮状态
一、继承自UITextfield自定义一个SSTouchTextField代码如下:#import "SSTouchTextField.h"@implementation SSTouchTextField#pragma mark - Private- (void)setBackgroundHighlighted:(BOOL)highlighted{ [UIView animateWithDuration:0.3f delay:0.f options:UIViewAnimationOp...…
-
iOS单独对年月日加减
1、当前时间减去18年+ (NSDate *)dateWithYearsBeforeNow:(NSInteger)year{ NSDate *currentDate = currentDate = [NSDate date]; NSCalendar *calendar = nil; if (IOS8Higher) { calendar = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierGrego...…
-
iOS开发 UIlabel 文字两边对齐
1、给UIlabel添加一个分类即可,代码如下: 必须导入这个头文件:CoreText/CoreText.h- (void)changeAlignmentRightandLeft{ CGRect textSize = [self.text boundingRectWithSize:CGSizeMake(self.frame.size.width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDr...…
-
iOS10新特性-自定义iMessage application
1、创建工程2、工程创建完成后的目录结构###3、接下来开始写代码//// MessagesViewController.swift// MessagesExtension//// Created by 岑志军 on 2016/9/28.// Copyright © 2016年 cen. All rights reserved.///* 虽然没有严格限制,但是苹果建议的表情文件大小: 1. Small: 100 x 100 pt @3x scale (300 x 300 pixel...…
-
Swift-单例
标准写法:// 在swift中,类方法是不允许定义静态变量的 static var once_t: dispatch_once_t = 0 static var instance: NetWorkTools? class func sharedNetWorkTools() -> NetWorkTools { dispatch_once(&once_t) { instance = NetWorkTools() ...…
-
Swift开发-代理
在iOS开发中经常会用到代理,Swift开发中的代理这样写:1、首先定义一个协议// swift中如何定义协议: 必须遵守NSObjectProtocolprotocol VisitorViewDelegate : NSObjectProtocol{ // 登录回调 func loginBtnWillClick() // 注册回调 func regiserBtnWillClick()}2、方法实现func loginBtnClick(){ delega...…
-
HTML5选择器
最近刚开始学习HTML5,记录一下自己学习的笔记,方便以后查阅: 首先选择器的常用分类: 标签选择器div{ color: red; } 类选择器.one{ color: yellow; } id选择器,注意id是唯一的标示,不能用于其他标签#main{ font-size: 40px; } 后代选择器#test1 div{ color: black; font-size: 50px;...…
-
HTML5-css样式分类
行内样式<body><!--行内样式--> <div style="font-size: 30px; color: red; background-color: blue;">121221323231221</div> <div style="font-size: 30px; color: red; background-color: blue;">121221323231221</div> &l...…
-
HTML标签分类
HTML有N多标签,根据显示的类型,主要可以分为3大类 块级标签: 独占一行的标签 能随时设置宽度和高度(比如div、p、h1、h2、ul、li) <style> div{ background-color: red; width: 200px; height: 50px; } p{ background-co...…