自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(81)
  • 资源 (3)
  • 收藏
  • 关注

原创 iOS UIImage生成高性能圆角图片

- (void)imageWihtSize:(CGSize)size radius:(CGFloat)radius backColor:(UIColor *)backColor completion:(void(^)(UIImage *image))completion{ // 异步绘制裁切 dispatch_async(dispatch_get_global_queue(0, 0)

2017-11-27 11:19:15 947

原创 iOS 版本检测更新

#pragma mark - 检查更新- (void)checkVersion{ if ([AppID length] < 1) { return; } NSString *url = [NSString stringWithFormat:@"http://itunes.apple.com/lookup?id=%@",AppID]; NSMutabl

2017-11-15 10:02:44 681

原创 WKWebView内容自适应宽度

NSString *jScript = @"var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width'); document.getElementsByTagName('head')[0].appe

2017-11-13 15:36:27 3638 1

原创 UIWebView&WKWebView获取网页高度

实测,必需要延迟一会儿才能获取正确高度。 -(void)webViewDidFinishLoad:(UIWebView *)webView { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ CGFloat

2017-11-09 17:27:46 226

原创 UIDocumentInteractionController 的使用

//// ViewController.m// pdfViewer//// Created by Johnay on 17/9/28.// Copyright © 2017年 Johnay. All rights reserved.//#import "ViewController.h"@interface ViewController ()<UIDocumentInterac

2017-09-30 15:10:55 939

原创 iOS 控制textField只能输入指定字符

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { if ([textField == yourTextField) { if (![self validateNumber:str

2017-08-25 11:35:16 331

原创 iOS 精确控制textField输入的小数位数

直接在代理方法中写代码- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { if (textField == yourTextField) { NSString * toBeStri

2017-08-25 11:30:46 340

原创 一个iOS程序员自己写代码将Kindle中我的剪贴内容筛选提取出来

//// ViewController.m// readFile//// Created by Johnay on 17/8/22.// Copyright © 2017年 Johnay. All rights reserved.//#import "ViewController.h"@interface ViewController ()<UIScrollViewDelega

2017-08-22 11:33:19 394

原创 UIImage 颜色渲染imageWithRenderingMode

UIImageView *imgV = [[UIImageView alloc] initWithFrame:CGRectMake(100,200,100,100];imgV.image = [[UIImage imageNamed:@"多边形-1"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];imgV.tintColo

2017-08-16 11:46:22 269

原创 iOS 正则表达式判断3个正数相乘

#import "ViewController.h"#import "AFNetworking.h"@interface ViewController (){ UITextField *textF;}@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; textF =

2017-08-14 10:47:22 440

原创 iOS 防止UIButton按钮重复点击

- (void)viewDidLoad{ [super viewDidLoad]; // 1. 创建 btn 并添加点击事件 UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; [btn setFrame:CGRectMake(100, 100, 100, 60)]; btn.backgro

2017-08-10 10:06:48 294

原创 iOS开发自动检测内存泄漏神器MLeaksFinder

给大家介绍一个内存检测神器,只需要用cocoaPods安装,无需导入任何头文件即可自动检测内存泄漏。GitHub地址 https://github.com/Zepo/MLeaksFindercocoaPods安装代码:pod ‘MLeaksFinder’安装后效果如下:最后如果想关闭自动检测功能,只需要将MLeaksFinder.h文件中第11行注释去掉即可!

2017-07-25 11:16:45 2425

原创 iOS 使用UIPickerView三级联动实现选择日期年月日

这里面有很多自定义的宏,效果图在下面,如果想要这个效果的朋友,不妨花几分钟把里面的宏改下等不报错了,直接用这下面的代码调用就可以了! 调用代码 SelectTimeV *selectTimeV = [[SelectTimeV alloc] init]; selectTimeV.block = ^(NSString *timeStr) { if (timeStr)

2017-07-24 17:16:15 8522 2

原创 iOS 任意布局UIButton中的图片与文字

- (void)setup{ self.titleLabel.textAlignment = NSTextAlignmentCenter;}- (instancetype)initWithFrame:(CGRect)frame{ if (self = [super initWithFrame:frame]) { [self setup]; } r

2017-07-24 16:37:33 334

原创 iOS 将json文件转为plist文件

NSString *path = [[NSBundle mainBundle] pathForResource:@"address.json" ofType:nil]; NSLog(@"path = %@",path); NSArray *array = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOf

2017-07-24 08:41:57 1684

原创 iOS 解决打包上传报This action could not be completed. Try again. (-22421)问题

终端执行三条命令完美解决尊重原创者劳动成果哈cd ~ mv .itmstransporter/ .old_itmstransporter/ “/Applications/Xcode.app/Contents/Applications/Application Loader.app/Contents/itms/bin/iTMSTransporter” 注意:一定要等第三条命令执行完毕才可以

2017-05-11 14:41:49 8220 17

原创 iOS开发中获取短信验证码倒计时按钮的实现

-(void)startTime{ __block int timeout=59; //倒计时时间 dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_source_t _timer = dispatch_source_create(D

2016-11-17 17:31:03 304

原创 解决tableView无数据时还显示横线及线条显示不全问题

//解决tableView无数据时还显示横线问题 UIView *v = [[UIView alloc] initWithFrame:CGRectZero]; [self.tableView setTableFooterView:v];//解决cell线条显示不全-(void)viewDidLayoutSubviews { if ([self.tableView respo

2016-11-07 17:02:52 2812

原创 UIImage图片转成Base64字符串

//UIImage图片转成Base64字符串:UIImage *originImage = [UIImage imageNamed:@"originImage.png"];NSData *data = UIImageJPEGRepresentation(originImage, 1.0f);NSString *encodedImageStr = [data base64EncodedStrin

2016-11-04 11:59:01 829

原创 AFN用Post发送Json数据

NSDictionary * arr = @{ @"userName":@"408131213@qq.com", @"passWord":@"111111", @"longitudes":@"changsha",

2016-10-17 15:46:38 1808

原创 安装CocoaPods报错,The dependency AFNetworking (~> 3.1.0) is not used in any concrete target

安装CocoaPods报错:[!] The dependency AFNetworking (~> 3.1.0) is not used in any concrete target. 今天新机装cocopods时,等安装完毕发觉出现[!] The dependency AFNetworking (~> 3.1.0) is not used in any concrete target.这个警告。

2016-10-17 09:42:24 1178

原创 AVPlayerLayer播放网络音视频

#import "ViewController.h"#import <AVFoundation/AVFoundation.h>@interface ViewController ()@property (weak, nonatomic) IBOutlet UISegmentedControl *segmentControl;//播放对象@property (nonatomic, strong

2016-10-12 15:00:04 1918

原创 AVAudioPlayer播放本地音频

#import "ViewController.h"#import <AVFoundation/AVFoundation.h>@interface ViewController ()//记录systemSoundID@property (nonatomic, assign) SystemSoundID systemID;//记录播放器对象@property (nonatomic, stro

2016-10-12 14:56:02 408

原创 MKMapView绘制路线

#import "ViewController.h"#import <MapKit/MapKit.h>@interface ViewController ()<MKMapViewDelegate>@property (weak, nonatomic) IBOutlet MKMapView *mapView;@property (nonatomic, strong) CLGeocoder *ge

2016-10-12 14:40:33 638

原创 MKMapView的Annotation使用

#import "ViewController.h"#import <MapKit/MapKit.h>#import "TRAnnotation.h"@interface ViewController ()<MKMapViewDelegate>@property (weak, nonatomic) IBOutlet MKMapView *mapView;@property (nonatomi

2016-10-12 14:38:12 728

原创 MKMapView使用

#import "ViewController.h"#import <MapKit/MapKit.h>@interface ViewController ()<MKMapViewDelegate>@property (weak, nonatomic) IBOutlet MKMapView *mapView;@property (nonatomic, strong) CLLocationMana

2016-10-12 14:25:00 302

原创 CoreLocation定位

#import "ViewController.h"#import <CoreLocation/CoreLocation.h>@interface ViewController ()<CLLocationManagerDelegate>//必须把CLLocationManger声明属性@property (nonatomic, strong) CLLocationManager *mgr;@en

2016-10-12 14:20:10 204

原创 NSJSONSerialization使用

- (IBAction)convertJSON2Foundation:(id)sender { //需求:从网络中请求天气的JSON数据, 解析指定的值,显示到textView上 //0.天气对应url NSURL *weatherURL = [NSURL URLWithString:@"http://www.raywenderlich.com/demos/weather_s

2016-10-12 11:30:52 485

原创 Json本地解析

- (void)viewDidLoad { [super viewDidLoad]; //1.获取文件的路径 NSString *jsonFilePath = [[NSBundle mainBundle] pathForResource:@"test.json" ofType:nil]; //2.读取文件内的数据(NSData类型:一般服务器返回的数据类型是NSData

2016-10-12 11:17:04 219

原创 AFNetworking发送get和post请求

#import "ViewController.h"#import "AFNetworking.h"@interface ViewController ()@end@implementation ViewController- (IBAction)sendHTTPGetRequest:(id)sender { //0.准备url的字符串 NSString *urlStr = @"h

2016-10-12 11:10:58 337

原创 NSURLSessionDownloadTask下载图片

#import "ViewController.h"@interface ViewController ()<NSURLSessionDownloadDelegate>//显示进度label@property (weak, nonatomic) IBOutlet UILabel *progressPercentLabel;//进度视图@property (weak, nonatomic) I

2016-10-12 11:00:53 789

原创 URLSession数据协议下载图片

#import "ViewController.h"@interface ViewController ()<NSURLSessionDataDelegate>@property (weak, nonatomic) IBOutlet UIImageView *imageView;@property (weak, nonatomic) IBOutlet UIProgressView *progre

2016-10-12 10:40:41 357

原创 GCD实现下载图片操作

#import "TRTableViewController.h"#import "TRDataManager.h"#import "TRAlbum.h"#import "TRTableViewCell.h"@interface TRTableViewController ()@property (nonatomic, strong) NSArray *albumsArray;//存储下载好

2016-10-12 10:32:24 273

原创 WKWebView使用

#import "ViewController.h"#import <WebKit/WebKit.h>@interface ViewController ()<WKNavigationDelegate>@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; //1.创建NSURL

2016-10-12 10:05:15 234

原创 UIWebView使用

@interface ViewController ()<UIWebViewDelegate>@property (weak, nonatomic) IBOutlet UIWebView *webView;@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; //1.创建远程NSU

2016-10-12 10:02:23 186

原创 NSBlockOperation使用

- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. //手动设置任务之间依赖关系,进而改变自动的执行顺序 [self createDependency];}- (void)createDep

2016-10-12 09:41:25 1433

原创 KVO使用

//1.创建观察者对象;创建被观察者对象 TRBank *bank = [TRBank new]; //2.使用KVC方式给被观察者对象设置余额 [bank setValue:@1000.5 forKey:@"accountBalance"]; //3.被观察者调用addObserver方法,添加观察动作 /* 参数一:指定观察对象的属性名字(属性路径)

2016-10-12 09:29:49 196

原创 KVC使用

//先用init方式初始化person对象 TRPerson *firstPerson = [[TRPerson alloc] initWithName:@"Maggie" withAge:18]; //点语法获取 NSLog(@"使用点语法获取名字:%@;年龄:%d", firstPerson.name, firstPerson.age); //KVC方式一获取(针

2016-10-12 09:22:31 204

原创 创建单例

static TRDataManager *_dataManagerByUnsafe = nil;+ (instancetype)sharedDataManagerByUnsafe { if (!_dataManagerByUnsafe) { _dataManagerByUnsafe = [[TRDataManager alloc] init]; } ret

2016-10-12 09:09:40 174

原创 dispatch_group_t使用

//1.创建一个group组对象 dispatch_group_t group = dispatch_group_create(); //2.添加两个任务(5s; 8s);全局队列+异步执行 dispatch_group_async(group, dispatch_get_global_queue(0, 0), ^{ //子线程执行 NSLog

2016-10-12 09:02:31 981

全国省市plist文件,带全部完整地址编码

全国省市plist文件,带全部完整地址编码;

2017-07-24

全国省市plist文件,带部分地址编码,不完整

包含全国所有省市地区,但地址编码不完整

2017-07-24

iOS笔试题(带答案)

最新iOS笔试题大全

2016-06-20

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除