自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 关于深拷贝和浅拷贝的理解

浅拷贝:只拷贝指针,相当于引用计数+1 (不可变数组) 深拷贝:连同属性拷贝出一个新的对象。 自定义对象如果想要拷贝需要遵循NSCopy协议。 (没实现的话使用copy会直接崩溃)。关于数组的修饰 (字典同理)1.不可变数组用copy修饰的原因 (NSString使用copy修饰同理) 方式传入的是一个可变数组。如果使用strong修饰,万一传入的数组在别的地方改变了,会影响...

2018-04-09 10:00:04 312

原创 项目添加CocoaPod

1:cd定位到工程文件夹位置 2:vim Podfile 创建文件 3:输入i进入编辑模式,然后输入以下内容编辑 platform:ios,’9.0’ target”工程名”do pod ‘AFNetworking’ pod’Masonry’ end然后esc,输入: wq 回车后 pod install安装即可

2017-10-24 14:46:04 802

原创 UIScrollView

1.contentOffset CGPointMake(20, 20),相当于视图从20,20开始显示,也就相当于整个视图想做向上20移动。

2017-08-25 14:03:59 345

原创 数组字典的copy,strong问题

1.拷贝或者引用对象为不可变对象时NSArray * nsarray = [NSArray arrayWithObject:@"1"];self.strongArr = nsarray;self.copyingArr = nsarray; 打印地址可以看到是同样的,因为对于不可变数组,字典的copy是浅拷贝。2.NSArray何时用strong会出错? 可以看到strong修饰时,self.

2017-08-25 10:15:47 455

原创 定时器的几种使用方式。

1.NSTimeNSTime有2中常见的初始化方式, 第一种是self.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(printCount) userInfo:nil repeats:YES];这种初始化方式会对当前控制器强引用,所以在离开页面的时候一定要执行[self.timer

2017-08-13 16:33:11 552

原创 使用Masonry设置自适应高度的UITableviewHeadView

首先是懒加载部分- (UIView *)headView{ if (!_headView) { _headView = [[UIView alloc]init]; _headView.backgroundColor = HEXColor(0xf2f2f2); _headBtn = [[UIButton alloc]init];

2017-08-07 15:58:15 1361

原创 环信心得

1–关于会话 (conversation) 官方定义是:操作聊天消息EMMessage的容器,在SDK中对应的类型是EMConversation。//生成message EMMessage * message = [[EMMessage alloc]initWithConversationID:@"5000" from:form to:@"test2" body:body ext:nil]

2017-07-20 22:53:48 394

原创 iOS本地存储 plist文件和归档

不管是写入plist文件还是归档 都会覆盖之前文件里的所有内容 而不是添加- (void)viewDidLoad { [super viewDidLoad]; UIButton * btn = [[UIButton alloc]initWithFrame:CGRectMake(50, 100, 50, 50)]; [btn setBackgroundColor:[UIColor

2017-07-13 16:44:55 510

原创 iOS BezierPath 贝塞尔曲线的绘制

//绘制矩形- (void)drawSequl{ UIColor * color =[UIColor redColor]; //设置画笔颜色 [color setFill]; UIRectFill(CGRectMake(10, 10, 100, 100));}//绘制自定义矩形- (void)drawDiySqul{ //设置线条颜色 UIC

2017-06-07 15:49:11 1557

原创 UIAlertController 在didSelectRowAtIndexPath里 有时候点了半天才出来

dispatch_async(dispatch_get_main_queue(), ^{ [self presentViewController:alert animated:YES completion:nil]; });

2017-05-04 14:29:05 353

原创 UIScrollView 的contentOffset和contentInset的区别

1.contentOffset:相当于滑动到指定位置。初试图所示 设置 myScroll.contentOffset =CGPointMake(40, 50); 后如下图所示,即从(40,50)开始显示,相当于左移 40 上移 50。 1.contentInset:相当于对象的起始点变化(上左下右)。 设置myScroll.contentInset =UIEdgeInsetsMake(50,

2017-03-15 13:07:53 847

原创 iOS 常用方法

1.获取对象相对于屏幕的位置UIWindow * window=[[[UIApplication sharedApplication] delegate] window];CGRect rect=[textField convertRect: textField.bounds toView:window];

2017-03-15 11:05:40 466

原创 iOS 添加日历事件

1.导入头文件 #import //事件市场 EKEventStore *eventStore = [[EKEventStore alloc] init]; //6.0及以上通过下面方式写入事件 if ([eventStore respondsToSelector:@selector(requestAccessToEntityType:completion:)])

2017-03-15 10:42:04 590

原创 文件管理

1.文件的复制NSFileManager * manager =[NSFileManager defaultManager];//获取资源文件的路径NSString * filePath =[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"hangC.plist"];//本地沙箱路径NSString *

2017-03-08 15:44:01 276

原创 self.edgesForExtendedLayout = UIRectEdgeNone;

1.self.edgesForExtendedLayout = UIRectEdgeNone;属性edgesForExtendedLayout,意思大概是边缘向四周展开edgesForExtendedLayout 值是结构体,默认值是 UIRectEdgeAll,也就是说,当一个控制器要往父控制器添加的时候,上下左右填充满整个屏幕。例如1:UIViewController添加到uiNavContro

2017-01-06 09:45:47 2638

原创 iOS PhotoKit

PhotoKit的基本构成:PHAsset:代表照片库中的一个资源,和ALAsset类似, 通过PHAsset可以获取和保存资源。PHFetchOptions:获取资源时的参数,可以传nil,即使用系统默认值。PHAssetCollection:PHCollection的子类,表示一个相册或者一个时刻,或者是一个智能相册。PHFetchResult:表示一系列的资源结果集合,也可以是相册的集合,从P

2016-12-26 11:46:28 592

原创 iOS block小记

block就像是封装了一段代码,设置其输入源和内部的逻辑运算,当调用的时候才执行里面的代码。

2016-12-20 14:22:30 367

原创 cocos2d——动作

注:设置成员变量 private: cocos2d::Sprite* sprite;1.移动auto moveto =MoveTo::create(2, Vec2(40, 80));sprite->runAction(moveto);2.动作组(Sequence)auto hideAction = Hide::create();auto moveTo = MoveTo::create

2016-12-15 14:19:16 431

原创 cocos2d杂记

1.除了layer的setPosition是用的左下角,其他是指的中心点

2016-12-15 11:49:21 300

原创 cocos2d学习笔记——基础控件

通用的高度 auto visibleSize =Director::getInstance()->getVisibleSize(); Vec2 origin =Director::getInstance()->getVisibleOrigin(); 1.按钮auto startItem =MenuItemFont::create("Start", CC_CALLBACK_1(NextScene

2016-12-15 10:23:11 452

原创 ios 如果获取cell上控件相对于屏幕的坐标

UIWindow * window=[[[UIApplication sharedApplication] delegate] window];CGRect frame=[self convertRect: self.bounds toView:window];textfield不被键盘遮挡UIWindow * window=[[[UIApplication sharedApplication]

2016-12-13 14:29:53 3970

原创 iOS CGImageRef

图片截取 UIImageView * imgView =[[UIImageView alloc]initWithFrame:CGRectMake(0, 100, 420, 375)]; [self.view addSubview:imgView]; UIImage * img =[UIImage imageNamed:@"zc.jpg"]; CGImageRef imgR

2016-12-09 17:12:35 587

原创 UIKit Dynamics

1.重力效果 UIImageView * lview =[[UIImageView alloc]initWithFrame:CGRectMake(20, 100, 40, 40)]; lview.image =[UIImage imageNamed:@"zc.jpg"]; [self.view addSubview:lview]; animator = [[UIDynam

2016-12-08 16:18:39 266

原创 alloc init问题

for (int i =0; i<4; i++) { btn =[[UIButton alloc]initWithFrame:CGRectMake(40+60*i, 100, 40, 40)]; btn.backgroundColor =[UIColor redColor]; btn.tag =100+i; [btn addTarget

2016-12-03 13:37:04 308

转载 iOS获取键盘高度

- (void)viewDidLoad{ [super viewDidLoad]; //增加监听,当键盘出现或改变时收出消息 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWil

2016-12-01 09:20:34 804

原创 iOS UILabel富文本自适应高度

UILabel * chiLabel =[[UILabel alloc]initWithFrame:CGRectMake(10, 100, 200, MAXFLOAT)]; chiLabel.backgroundColor =[UIColor whiteColor]; chiLabel.numberOfLines =0; [self.view addSubview:chiLabel

2016-11-30 17:32:57 1383

原创 xcode自动注释快捷键

Command + Option + /

2016-11-16 16:16:00 1188

原创 iOS center属性

center属性是指当前view在其父view上的位置,center.x和center.y是以父view为参考系的。举个例子 UIView * view1 =[[UIView alloc]initWithFrame:CGRectMake(40, 100, 100, 100)]; view1.backgroundColor =[UIColor orangeColor]; [sel

2016-11-16 13:32:14 1587

原创 iOS状态栏颜色修改

1,首先要设置View controller-based status bar appearance =NO; 2,如果要全局改变,在Targets修改即可 3,如果要每个页面单独修改 [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:NO];

2016-11-14 11:01:53 463

原创 iOS绘制图形(三角形)

-(void)drawRect:(CGRect)rect{ //获取上下文 CGContextRef ctx = UIGraphicsGetCurrentContext(); //开始绘画 CGContextBeginPath(ctx); //起始点 CGContextMoveToPoint (ctx, CGRectGetMaxX(rect), CGR

2016-11-11 15:50:52 1187

原创 iOS支持多语言

多语言的使用有些时候,我们的App可能不只是针对国内的用户,这时候就需要支持多种语言,好让不同国家的用户都可以使用,这时候就要支持多语言了。找到info→Localizations→+选择需要添加的语言 新建strings文件,名字为Localizable 3.为Localizable.strings添加不同的支持语言 4.在string文件中设置不同的key值对应在不同语言下应该显示的字符

2016-11-10 15:13:44 462

原创 iOS DES加密和解密

这里写代码//加密- (NSString *) encryptUseDES:(NSString *)plainText key:(NSString *)key{ NSString *ciphertext = nil; const char *textBytes = [plainText UTF8String]; NSUInteger dataLength = [plain

2016-11-09 17:32:35 3674 1

原创 ios中oc的js的交互

1,js调用oc#import 在webview的代理方法里JSContext *context =[webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];// 打印异常context.exceptionHandler =    ^(JSContext *co

2016-10-27 15:40:16 349

原创 iOS二维码生成

- (UIImage *)encodeQRImageWithContent:(NSString *)content size:(CGSize)size { UIImage *codeImage = nil; NSData *stringData = [content dataUsingEncoding: NSUTF8StringEncoding];

2016-10-18 15:10:04 369

原创 如何让控件只有一个圆角

//指定矩形大小 CGRect rect =CGRectMake(50, 300, 100, 100); //设置圆角半径 CGSize size =CGSizeMake(20, 20); //拿出需要设置改动的角 UIRectCorner corners = UIRectCornerBottomRight; //综合上两部的具体操作 UIB

2016-10-14 17:28:08 344

原创 gif图片的合成

//gif的合成-(void)makeGif{ //获取图片 NSMutableArray * imgArray =[NSMutableArray new]; for (int m=0; m<11; m++) { NSString * savePath =[NSHomeDirectory() stringByAppendingFormat:@"/Docu

2016-09-28 16:38:15 656

原创 Gif图的分解

NSString * path =[[NSBundle mainBundle]pathForResource:@"dog" ofType:@"gif"]; NSData * data =[NSData dataWithContentsOfFile:path]; CGImageSourceRef source = CGImageSourceCreateWithData((__brid

2016-09-28 14:47:24 6854 2

原创 更新xcode8之后模拟器没了

关掉xcode重新打开一下就可以了。。。。

2016-09-28 14:43:10 1934 1

原创 在xib上拖Scrollview位置出现偏差

self.automaticallyAdjustsScrollViewInsets =NO;

2016-09-28 09:25:11 398

原创 CSS样式小笔记

外链CSS样式1,rel="stylesheet" type="text/css"2,标签位置一般写在标签之内后代选择器.first>span (设置所有的第一代子元素).first span (设置所有子元素)*{}  (通用选择器 设置全部)a:hover{ color:red;} (鼠标滑过字体颜色变化)优先级问题标签的权值为1,类选择

2016-09-23 18:01:57 320

空空如也

空空如也

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

TA关注的人

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