- 博客(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 986
原创 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 725
原创 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 3679 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 244
原创 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 957
原创 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 363
原创 iOS 精确控制textField输入的小数位数
直接在代理方法中写代码- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { if (textField == yourTextField) { NSString * toBeStri
2017-08-25 11:30:46 374
原创 一个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 421
原创 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 290
原创 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 477
原创 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 313
原创 iOS开发自动检测内存泄漏神器MLeaksFinder
给大家介绍一个内存检测神器,只需要用cocoaPods安装,无需导入任何头文件即可自动检测内存泄漏。GitHub地址 https://github.com/Zepo/MLeaksFindercocoaPods安装代码:pod ‘MLeaksFinder’安装后效果如下:最后如果想关闭自动检测功能,只需要将MLeaksFinder.h文件中第11行注释去掉即可!
2017-07-25 11:16:45 2444
原创 iOS 使用UIPickerView三级联动实现选择日期年月日
这里面有很多自定义的宏,效果图在下面,如果想要这个效果的朋友,不妨花几分钟把里面的宏改下等不报错了,直接用这下面的代码调用就可以了! 调用代码 SelectTimeV *selectTimeV = [[SelectTimeV alloc] init]; selectTimeV.block = ^(NSString *timeStr) { if (timeStr)
2017-07-24 17:16:15 8589 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 369
原创 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 1710
原创 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 8312 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 335
原创 解决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 2855
原创 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 874
原创 AFN用Post发送Json数据
NSDictionary * arr = @{ @"userName":@"408131213@qq.com", @"passWord":@"111111", @"longitudes":@"changsha",
2016-10-17 15:46:38 1830
原创 安装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 1216
原创 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 1969
原创 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 423
原创 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 693
原创 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 754
原创 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 342
原创 CoreLocation定位
#import "ViewController.h"#import <CoreLocation/CoreLocation.h>@interface ViewController ()<CLLocationManagerDelegate>//必须把CLLocationManger声明属性@property (nonatomic, strong) CLLocationManager *mgr;@en
2016-10-12 14:20:10 241
原创 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 518
原创 Json本地解析
- (void)viewDidLoad { [super viewDidLoad]; //1.获取文件的路径 NSString *jsonFilePath = [[NSBundle mainBundle] pathForResource:@"test.json" ofType:nil]; //2.读取文件内的数据(NSData类型:一般服务器返回的数据类型是NSData
2016-10-12 11:17:04 235
原创 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 359
原创 NSURLSessionDownloadTask下载图片
#import "ViewController.h"@interface ViewController ()<NSURLSessionDownloadDelegate>//显示进度label@property (weak, nonatomic) IBOutlet UILabel *progressPercentLabel;//进度视图@property (weak, nonatomic) I
2016-10-12 11:00:53 828
原创 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 389
原创 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 307
原创 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 262
原创 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 203
原创 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 1464
原创 KVO使用
//1.创建观察者对象;创建被观察者对象 TRBank *bank = [TRBank new]; //2.使用KVC方式给被观察者对象设置余额 [bank setValue:@1000.5 forKey:@"accountBalance"]; //3.被观察者调用addObserver方法,添加观察动作 /* 参数一:指定观察对象的属性名字(属性路径)
2016-10-12 09:29:49 215
原创 KVC使用
//先用init方式初始化person对象 TRPerson *firstPerson = [[TRPerson alloc] initWithName:@"Maggie" withAge:18]; //点语法获取 NSLog(@"使用点语法获取名字:%@;年龄:%d", firstPerson.name, firstPerson.age); //KVC方式一获取(针
2016-10-12 09:22:31 222
原创 创建单例
static TRDataManager *_dataManagerByUnsafe = nil;+ (instancetype)sharedDataManagerByUnsafe { if (!_dataManagerByUnsafe) { _dataManagerByUnsafe = [[TRDataManager alloc] init]; } ret
2016-10-12 09:09:40 188
原创 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 1005
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人