自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(82)
  • 收藏
  • 关注

原创 iOS_SQL语句详解

// 需要在静态区定义一个指针 (让这个指针指向的对象 从程序开始到结束 一直存在 程序结束后被系统自动释放)static sqlite3 *db = nil;// 打开数据库- (sqlite3 *)openDB { // 判断数据库是否存在 如果存在直接返回 // 不存在 则创建一个并打开 if (db != nil) { return...

2018-10-15 17:31:32 245

原创 打印中文

#import @interface NSArray (MyLog)@end@interface NSDictionary (MyLog)@end#import "NSArray+MyLog.h"@implementation NSArray (MyLog)/* 打印中文 */- (NSString*)descriptionWithLocale:

2017-11-17 14:53:18 341

原创 Tableview添加索引

//添加索引栏标题数组- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{ NSMutableArray *resultArray =[NSMutableArray arrayWithObject:UITableViewIndexSearch]; fo

2017-11-17 14:38:45 331

原创 Label适应文字大小

- (CGFloat)infoLbSize{ CGSize maxSize = CGSizeMake(self.frame.size.width, MAXFLOAT); NSDictionary *attrs = @{NSFontAttributeName : self.infoLb.font}; // 计算文字占据的高度 CGSize size = [self.

2017-09-19 16:34:07 424

原创 WebView加header

写一个类继承NSURLProtocol,在 + (BOOL)canInitWithRequest:(NSURLRequest *)request 方法拦截request为request添加请求头,这样所有的webview操作请求都会调到这里,为request添加请求头,而且不影响webview的goBack方法返回+ (void)load { [NSURLProtoc

2017-09-15 15:37:52 746

原创 UIlabel,文字复制

首先创建一个类继承于UILabel;因为label默认是不接收事件的,我们需要自己给label添加touch事件。-(void)addTouch{ self.userInteractionEnabled = YES; //用户交互的总开关 UILongPressGestureRecognizer *touch = [[UILongPress

2017-09-07 11:33:32 227

原创 UIAlertConntroller

默认样式UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"标题" message:@"这个是UIAlertController的默认样式" preferredStyle:UIAlertControllerStyleAlert];UIAlertAction *cancelAct

2017-09-06 17:39:19 392

原创 iOS 获取步数等健康信息

导入HealthKit.frameworkinfo.plist中添加权限配置 NSHealthShareUsageDescription App需要您的同意,才能访问健康分享 capabilities里面打开HealthKit引入#import属性{ HKHealthStore *store;}@property (n

2017-09-05 15:56:56 736

原创 调用麦克风录音及播放

导入AVFoundation.framework引入#import//定义属性{ //录音器 AVAudioRecorder *recorder; //播放器 AVAudioPlayer *player; NSDictionary *recorderSettingsDict; //录音名字 NSString *playName;

2017-09-05 14:42:33 1162

原创 调用铃声及震动

首先导入  #import//同时调用铃声及震动:SystemSoundID soundID = 1007;AudioServicesPlaySystemSound(soundID);//仅振动:AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);用户自定义音效//音效文件路径 NSString *path

2017-09-04 15:44:00 631

原创 调用系统设置页面和WIFI设置页面

调用系统设置页面NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString]; if ([[UIApplication sharedApplication] canOpenURL:url]) { [[UIApplication sharedApplication] openURL:url];

2017-09-04 15:08:55 381

原创 调用系统浏览器打开网址

NSURL *url = [NSURL URLWithString:@"http://www.baidu.com"];[[UIApplication sharedApplication] openURL:url];

2017-09-04 15:02:41 605

原创 系统打电话,发短信功能

打电话功能//直接跳转到打电话的界面NSString *allString = [NSString stringWithFormat:@"tel:10010"];[[UIApplication sharedApplication] openURL:[NSURL URLWithString:allString]];//拨号之前会弹框询问用户是否拨号NSURL *url = [NSUR

2017-09-04 14:56:26 297

原创 xcode 字体样式

Font Family: American TypewriterFont: AmericanTypewriterFont: AmericanTypewriter-BoldFont Family: AppleGothicFont: AppleGothicFont Family: ArialFont: ArialMTFont: Arial-BoldMTF

2017-08-31 17:20:32 415

原创 自定义NSLog

/** 如果是调试阶段 ZYLog == NSLog */#ifdef DEBUG#define ZYLog(…) NSLog(__VA_ARGS__)/** 如果是发布程序 ZYLog替换为空 */#else#define ZYLog(…) #endif

2017-08-31 17:01:41 223

原创 退出程序

#pragma mark - 退出程序- (void)exitApplication { wulianAppDelegate *app = [UIApplication sharedApplication].delegate; UIWindow *window = app.window; [UIView animateWithDuration:0.5f a

2017-08-31 16:59:17 199

原创 CocoaPods 使用

1.初始化ruby环境(可省略)mkdir -p $HOME/Software/rubyexport GEM_HOME=$HOME/Software/rubyexport PATH=$PATH:$HOME/Software/ruby/bin2.打开终端执行指令      cd + 空格 + 拖文件     3.创建文件夹     vim Podfil

2017-08-31 16:52:02 152

原创 国际化/多语言

一.手动切换1.创建工程2.工程-PROJECT-info->Localizations,点“+”,选择(Chinese(Simplified))添加简体中文,英文Xcode自带有(English),所以不需要再次添加。3.创建strings文件,取名为Language.strings(自己随意命名,后缀为:.strings)(记得Targets要勾选项目)4.

2017-08-31 15:46:47 278

原创 固定/自定义图片 取色

固定图片取色-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ //触点对象 UITouch *touch=touches.anyObject; //触点位置 CGPoint touchLocation=[touch locationInView:self.colorImage];

2017-08-31 14:31:45 255

原创 提示框自动消失

/** * 弹框提示 */UIAlertView *alert = [[UIAlertViewalloc]initWithTitle:@"提示"message:@"2秒后将消失"delegate:nil cancelButtonTitle:nilotherButtonTitles:nil]; [alertshow]; // 2秒后执行 [self perf

2017-08-31 14:28:55 400

原创 字符串插入逗号

- (NSString *)addSeparatorForPriceString:(NSString *)priceStr{ NSMutableString *tempStr = priceStr.mutableCopy; NSRange range = [priceStr rangeOfString:@"."];//如果存在小数点,index就是小数点的位置 NSInt

2017-08-30 17:33:37 1747

原创 限制textfield只能输入数字

// 需要使用的textfield遵循代理- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { return [self validateNumber:string];}- (BOO

2017-08-30 17:31:24 737

原创 object转化成json,json格式字符串转字典,数组或字典转为json串

将object转化成json格式- (NSString *)objectToJsonString{ if ([NSJSONSerialization isValidJSONObject:self]) { NSError *error; //创超一个json从Data,NSJSONWritingPrettyPrinted指定的JSON数据产的空白

2017-08-30 17:26:56 1074

原创 获取时间间隔

- (NSInteger)getDifferenceByDate:(NSString *)date { //获得当前时间 NSDate *now = [NSDate date]; //实例化一个NSDateFormatter对象 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] ini

2017-08-30 17:23:19 281

原创 使用第三方APP打开文件

遵守协议 属性@property (nonatomic, strong) UIDocumentInteractionController *documentInteractionController;实现方法NSURL *url = [NSURL fileURLWithPath:[[HSDownloadManager alloc] filepathWithUrl:downlo

2017-08-30 17:21:04 347

原创 判断输入字符类型,汉字转拼音

中文- (BOOL) deptNameInputShouldChinese{ NSString *regex = @"[\u4e00-\u9fa5]+"; NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex]; if (![pred evaluateWith

2017-08-30 17:14:12 272

原创 iOS10需要添加的权限配置

NSPhotoLibraryUsageDescription App需要您的同意,才能访问相册 NSCameraUsageDescription App需要您的同意,才能访问相机 NSMicrophoneUsageDescription App需要您的同意,才能访问麦克风 NSLocationUsageDescription App需要您的同意,才能访问位置 NSL

2017-08-30 16:06:07 203

原创 让sdwebimage不缓存图片,每次都重新加载url

在AppDelegate didFinishLaunching的地方追加如下代码SDWebImageDownloader *imgDownloader = SDWebImageManager.sharedManager.imageDownloader; imgDownloader.headersFilter = ^NSDictionary *(NSURL *url, NSDictio

2017-08-30 15:44:18 5302

原创 访问https 绕过证书验证方法

AFNetworking:/* 关闭验证 */ AFSecurityPolicy *security = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone]; [security setValidatesDomainName:NO]; security.allowInvalidC

2017-08-30 15:41:03 1938

原创 视图抖动

- (void)shakeAnimationForView:(UIView *) view{ // 获取到当前的View CALayer *viewLayer = view.layer; // 获取当前View的位置 CGPoint position = viewLayer.position; // 移动的两个终点

2017-07-21 17:21:38 222

原创 View侧滑动画

1.创建ViewleftView = [[UIView alloc] initWithFrame:CGRectMake(-400, 80, 400, Kscreenheight-80)];2.点击Btn,View从侧边滑入页面,或滑出页面if (leftshow == NO) { leftshow = YES; [self.view addSubview

2017-07-20 10:50:35 183

原创 base64编码

给定一个字符串,对该字符串进行Base64编码,然后返回编码后的结果 //加密 -(NSString *)base64EncodeString:(NSString *)string { //1.先把字符串转换为二进制数据 NSData *data = [string dataUsingEncoding:NSUTF8StringEncodi

2017-07-20 10:43:15 308

原创 RSA加密

#pragma mark - 非对称加密- (NSString *)RSA:(NSString *)strname{ RSAEncryptor* rsaEncryptor = [[RSAEncryptor alloc] init]; NSString* publicKeyPath = [[NSBundle mainBundle] pathForResource:@"p

2017-07-20 10:38:58 243

原创 UISearchBar

1.更改搜索框放大镜图片[self.searchBar setImage:[UIImage imageNamed:@"搜索"]forSearchBarIcon:UISearchBarIconSearch state:UIControlStateNormal]; 2.取消按钮可一直点击UIButton *cancelBtn = [self.searchBarvalueForK

2017-07-18 18:33:21 224

原创 字符串截取

1.截取字符串NSString*string =@"iPhone";string = [string substringToIndex:2];//截取掉下标2之后的字符串NSLog(@"截取的值为:%@",string);  //iP[string substringFromIndex:2];//截取掉下标2之前的字符串NSLog(@"截取的值为:%@",strin

2017-07-18 18:17:32 355

转载 tableView的数据源及代理方法

UITableView的数据源(dataSource)和代理(delegate)UITableView需要一个数据源(dataSource)来显示数据,UITableView会向数据源查询一共有多少行数据以及每一行显示什么数据等。没有设置数据源的UITableView只是个空壳。凡是遵守UITableViewDataSource协议的OC对象,都可以是UITableView的数据源。

2016-03-30 15:36:54 2141

原创 iOS 调用系统相机和相册

一,创建button,触发点击事件,调用系统相机/相册选取头像- (IBAction)chooseUserPicAction:(id)sender { UIActionSheet *sheet; // 判断是否支持相机 if([UIImagePickerController isSourceTypeAvailable:UIImag

2016-03-22 15:20:06 489

原创 iOS蓝牙4.0开发

1.建立中心角色#import CBCentralManager *manager; manager = [[CBCentralManager alloc] initWithDelegate:self queue:nil]; 2.扫描外设(discover)[manager scanForPeripheralsWithServices:nil options:options];

2016-03-15 13:52:32 596

原创 UIViewController的生命周期

当一个视图控制器被创建,并在屏幕上显示的时候。 代码的执行顺序1、 alloc                                   创建对象,分配空间2、init (initWithNibName) 初始化对象,初始化数据3、loadView                          从nib载入视图 ,通常这一步不需要去干涉。除非你没有使用xib文件创建视图

2015-11-16 21:15:43 294

原创 iOS图文混排

在很多新闻类或有文字展示的应用中现在都会出现图文混排的界面例如网易新闻等,乍一看去相似一个网页,其实这样效果并非由UIWebView 加载网页实现。现在分享一种比较简单的实现方式iOS sdk中为我们提供了一套完善的文字排版开发组件:CoreText。CoreText库中提供了很多的工具来对文本进行操作,例如CTFont、CTLine、CTFrame等。利用

2015-11-16 20:52:56 519

空空如也

空空如也

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

TA关注的人

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