iOS常用方法总结

来源:互联网 发布:淘宝店铺怎么设置分类 编辑:程序博客网 时间:2024/05/08 23:13
1、禁止触摸

   组件名.userInteractionEnabled=YES;

2、定时器
  [NSTimer  ScheduledTimerWithInterVal:target:……];

3、Button圆角设置
  button.layer.cornerRadius=10.0;

4、文本对齐
 控件命.textAlignment=NSTextAlignmentLeft;

5、模态展示
[self presentViewController:alert animated:YES  completion:nil];

6、计时器停止
[self.timer invalidate]; ( invalidate 使无效)

7、控件的旋转
控件.transform=CGAffineTransformMakeRotation(0,1);

8、查询方法是否存在

[self.delegate respondsToSelector:@selector(manager:)]

9、textfield设置密码的格式

_textFieldPass.secureTextEntry = YES;

10、关闭其他布局方式

    imageV.translatesAutoresizingMaskIntoConstraints = NO;

11/ //设置登陆页面背景图片

    self.view.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"05.jpg"]];

12、-(Bool)isMemberofClass:(class)aClass
判断消息接受者是不是参数aClass类的对象
13、-(Bool)isKindOfClass:(class)aClass (是否是本类或子类)
14、-(Bool)isSubOfClass:(class)aClass

15、[self.refreshControl endRefreshing];系统自带的刷新停止

16、 groupTableViewBackgroundColor 浅灰色

17、在主线程中延迟一段时间执行(会阻塞主线程的一种做法)
  [self performSelector:@selector(delayMethod) withObject:nil afterDelay:1.0f];

18、根基tag值获取控件
  Chessman *chessman1=(Chessman *)[self.view viewWithTag:1];//获取控件

19、手势中包含一个可以拿到该控件的tag值的属性-------通过(控件.view.tag)
  各一个参数就类似于目标动作回调中带参数的Button一样。

20、
(1)在ViewController中有一个 childViewControllers属性 他是一个数组,可以存放子控制器
  [self addChildViewController:VC]
(2)在ViewController中 subViews中存着子视图的View 

【注】在一般的ViewController中可以使用的属性
    self.view.subviews//这个指的的是View
    self.childViewControllers//这个指的是Controller

21、没有个ViewController都会有一个 title属性(可读写)本地化标题供父类控制器使用。

22、代理方法也可以通过 self 进行调用

23、放射变换
(1)缩放 button.transform = CGAffineTransformMakeScale(scaleX,scaleY);
(2)旋转 CGAffineTransform t = CGAffineTransformRotate();
(3)平移  CGAffineTransform t = CGAffineTransformMakeTranslation(0,100);
         button.transfor = t;

24、UIViewController * vc = [self.storyboard instantiateViewControllerWithIdentifier:@"aV”];

25、指定根视图
 [UIApplication sharedApplication].keyWindow.rootViewController= vc;
   返回
            [UIApplicationsharedApplication].keyWindow.rootViewController= self.storyboard.instantiateInitialViewController;
1 0
原创粉丝点击