NJ学习积累2

来源:互联网 发布:微信淘宝专用转换工具 编辑:程序博客网 时间:2024/05/16 19:25

1. 当storyboard使用了layout布局:

如果在VC中想要修改位置,可以使用

@property (strong, nonatomic)IBOutletNSLayoutConstraint *topLayout;

topLayout.constant = 50;


2.动画实现

  UIKit只用UIView来展示动画,动画支持UIView下面的这些属性改变:

  • frame  
  • bounds  
  • center  
  • transform  
  • alpha 
  • backgroundColor 
  • contentStretch

{

  [UIView beginAnimations:nil context:nil];

    [UIView setAnimationDuration:2];

    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

    [UIView setAnimationDelegate:self];

    [UIView setAnimationDidStopSelector:@selector(stopDelegate)]; //动画执行完成后执行

    _animationFrame.frame = CGRectMake(150803030);

    [UIView commitAnimations];

}  

//代理执行

- (void)stopDelegate

{

//UIView Block动画

    [UIViewanimateWithDuration:2animations:^{

        _animationFrame.frame =CGRectMake(200,200,80,80);

    } completion:^(BOOL finished) {

        _animationFrame.backgroundColor = [UIColoryellowColor];

    }];


}

B.用CAPropertyAnimation的子类

主要针对CALayer进行设置

http://www.cnblogs.com/wendingding/p/3801157.html

http://www.cocoachina.com/bbs/read.php?tid=124506

3.把秒数转变成时间格式 85秒---》 00 :01:25

- (NSString *)timeFormatted:(int)totalSeconds
{
    int seconds = totalSeconds % 60; 
    int minutes = (totalSeconds / 60) % 60; 
    int hours = totalSeconds / 3600; 
    return [NSString stringWithFormat:@"%02d:%02d:%02d",hours, minutes, seconds]; 

4.ios时间戳转换时间

http://www.360doc.com/content/15/0120/16/20918780_442336474.shtml

5.ios 坐标转换

比如:cell上面有个label(10,0,50,50)-->转换成相应在self.view上的坐标

[cell convertRect:lable.point  toView:self.view];

// 将像素pointpoint所在视图转换到目标视图view中,返回在目标视图view中的像素值

- (CGPoint)convertPoint:(CGPoint)point toView:(UIView *)view;

// 将像素pointview中转换到当前视图中,返回在当前视图中的像素值

- (CGPoint)convertPoint:(CGPoint)point fromView:(UIView *)view;

http://blog.csdn.net/xuhuan_wh/article/details/8486337

6.UITextfield、UITextView对于字数限制:

当超过字符进行截取时候 ,会crash(尚未解决)

http://blog.sina.com.cn/s/blog_60f977e70101g4gj.html

7.发送邮件
 a.openURL
 b.MFMailComposeViewController

8.比如在uitableview上加入手势,会遮盖didSelectRow
 必须使用UIGestureRecognizerDelegate代理方法进行判断
  1. #pragma mark - UIGestureRecognizerDelegate  
  2. - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch  
  3. {  
  4.     // 输出点击的view的类名  
  5.     NSLog(@"%@", NSStringFromClass([touch.view class]));  
  6.       
  7.     // 若为UITableViewCellContentView(即点击了tableViewCell),则不截获Touch事件  
  8.     if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {  
  9.         return NO;  
  10.     }  
  11.     return  YES;  
  12. }  
http://blog.csdn.net/xiazailushang/article/details/10941471

9.关于app图标和Launchicon
https://developer.apple.com/library/ios/qa/qa1686/_index.html

10.gcd的串行、并行、延迟、先后顺序
dispatch_async、dispatch_group_async、dispatch_barrier_async、
dispatch_once

http://blog.sina.com.cn/s/blog_a3dbd02a0101b8y4.html

11. 颜色color 控件  
http://wafflesoftware.net/hexpicker/

12.查看文件的二进制hexdump

13.UIImagePickViewController 可以进行拍照和拍视频处理
关于ios7访问照相机隐私权限的设置
http://blog.sina.com.cn/s/blog_9d25acc60101icaz.html

14. 访问系统内的相册
AssetLibrary框架:ALAssetsLibrary、ALAssetsGroup、ALAsset类
http://my.oschina.net/u/1378445/blog/333052#OSC_h1_1

15.ContainerViewController 自定义VC集合

http://sandmoose.com/post/35714028270/storyboards-with-custom-container-view-controllers 


16.关于封装Http请求
步骤:
a.创建一个单利 

/**请求方法

*requestType:根据请求类型,设置url

*params:请求携带的参数

*三个block分别是成功

*

*/

typedef void (^UIEngineCompletionBlock)(id object);

typedef void (^UIEngineFailureBlock)(NSError *error);


- (id)bridgeExpressWithNetRuquestType:(NetRequestContentType)nrt 

params:(NSDictionary *)params 

successBlock:(UIEngineCompletionBlock)successBlock 

failBlock:(UIEngineCompletionBlock)failBlock 

errorBlock:(UIEngineFailureBlock)errorBlock;


或者这么封装

/**

 *  网络请求携带类型

 *

 *  @param requestType  请求类型

 *  @param ContentType  接口地址类型

 *  @param parms        内容

 *  @param successBlock 成功回调

 *  @param failBlock    失败回调

 *  @param errorBlock   错误回调

 */

//请求类型

typedef NS_ENUM (NSUInteger, NetRequestType) {

    NetRequestGET,    //get请求

    NetRequestPOST,    //post请求

};


//请求内容类型

typedef NS_ENUM (NSUInteger, NetRequestContentType) {

    NetRequestContent_None,

    NetRequestContent_Login,                // 登录

    NetRequestContent_Logout,               // 注销

    NetRequestContent_Personal,             // 个人资料

    NetRequestContent_ForgetPW,             // 忘记密码

    NetRequestContent_Register,             // 注册

    NetRequestContent_SMS 

}


typedef void (^HttpCompletionBlock)(id object);

typedef void (^HttpFailureBlock)(NSError *error);

typedef BOOL (^HttpIsReload)();

- (void)httpNetRuquestType:(NetRequestType)requestType 

requestContentType:(NetRequestContentType)ContentType 

params:(NSDictionary *)parms 

successBlock:(HttpCompletionBlock)successBlock 

failBlock:(HttpCompletionBlock)failBlock 

errorBlock:(HttpFailureBlock)errorBlock;

底层的实现:
使用AFNetWorking进行请求
17. UIView方法setNeedsDisplay和setNeedsLayout
a.这两个方法都是异步执行的。而setNeedsDisplay会自动调用drawRect方法,这样拿到UIGraphicsGetCurrentCurrentContext,就可以画画了。而setNeedsLayout会默认调用layoutSubviews,就可以处理子视图中的一些数据
http://blog.sina.com.cn/s/blog_a573f7990101cdpe.html





0 0
原创粉丝点击