2016.1.20个人总结

看完了”如何正确地写好一个界面”http://oncenote.com/2015/12/08/How-to-build-UI/里关于轻VC的探讨,感觉很有启发.现在都是为了功能而写的,VC类很臃肿,一定要改.

1.使用Xcode自带的静态分析工具 Product->Analyze可以找出代码潜在错误,如内存泄露,未使用函数和变量等

出现 value stored to dic during its initialization is never read
设置为:

NSDictionary * dic = nil;

以前为

NSDictionary * dic = [NSDictionary dictionary];

2.宏:
这里写图片描述
3.使用SWRevealViewController来实现左右侧拉
(1)确立中间视图和左右视图
(2)导入,在AppDelegate中写东西

// 左边
LeftViewController * leftViewController = [[LeftViewController alloc]init];
//    首页
 MiddleViewController * centerViewController = [[MiddleViewController alloc]init];
//    右边
RightViewController * rightViewController = [[RightViewController alloc]init];

SWRevealViewController * revealViewController = [[SWRevealViewController alloc]initWithRearViewController:leftViewController frontViewController:centerViewController];
    revealViewController.rightViewController = rightViewController;

//    浮动层离左边距的宽度
    revealViewController.rearViewRevealWidth = 260;
//    右边距离
    revealViewController.rightViewRevealWidth = 260;

 [revealViewController setFrontViewPosition:FrontViewPositionLeft animated:YES];

self.window.rootViewController = revealViewController;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];

(3)在MiddleViewController中添加

SWRevealViewController * revealController = self.revealViewController;
[self.view addGestureRecognizer:revealController.panGestureRecognizer];

4.限制TextField输入长度
(1)给textField添加事件

[YJtextField addTarget:self action:@selector(changeTextField:) forControlEvents:UIControlEventEditingChanged];

(2)实现方法

-(void)changeTextField:(UITextField *)textField{
//    限制输入长度,如果长度大于5的话,让textField的text长度控制在5以内
    if (textField.text.length > 5) {
        textField.text = [textField.text substringToIndex:5];
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值