简单常用代码

1、隐藏tabbar
ServiceSubViewController *controller = [[ServiceSubViewController alloc]init];
[controller setHidesBottomBarWhenPushed:YES];//加上这句就可以把推出的ViewController隐藏Tabbar
2、有关tableView
self.tab.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tab.showsVerticalScrollIndicator = NO;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
//scrollView自动布局关掉
self.automaticallyAdjustsScrollViewInsets = NO;
3.画边框 view
self.layer.cornerRadius = 6;
self.layer.borderWidth=2;
self.layer.borderColor = COLOR(129, 164, 189, 1).CGColor;

  • (void)dismiss
    {
    [self removeFromSuperview];
    }
    3、push页面简单化写法:不用引用头文件
    [self.navigationController pushViewController:[[NSClassFromString(@"TYRProduceViewController") alloc] init] animated:YES];
    4、@synchronized(self)
    @synchronized 的作用是创建一个互斥锁,保证此时没有其它线程对self对象进行修改。这个是objective-c的一个锁定令牌,防止self对象在同一时间内被其它线程访问,起到线程的保护作用。 一般在公用变量的时候使用,如单例模式或者操作类的static变量中使用。
    5、windows上添加视图interface UIView
    [[[UIApplication sharedApplication] keyWindow] addSubview:self];
    [self removeFromSuperview];
    6、static 和 const 作用
    static CGFloat const NVMTabBarHeight = 49;
    static 是在本类中此变量名在内存中只能被申请一次,再次申请此名字还是这个东西
    const 常量的意思 const后的数值不可改变
    7、weak self
    __weak typeof(self) wself = self;
    8、DEBUG 模式
    第一步

define Debug

//注释掉后需要输账号密码登录 不注释掉后反之
第二步

ifdef Debug

(debug模式)...

else

(非debug模式)...

endif

9、获取高度
CGRectGetHeight(_tabBarView.bounds)
10、
1)手机最顶端状态栏,把黑色字体显示成白色
在supporting Files里找到.plist文件找到required devic capabilities 中加上
最后一个选项
View controller-based status bar appearance
和倒数第九个这个
Status bar style 在这个后边选项选最后一个
Opaque black style
11、ARC设置
iOS中arc的设置与使用-fobjc-arc或者-fno-objc-arc
12、单例

  • (WebCacheHelper *)sharedInstance
    {
    static WebCacheHelper *helper;

    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
    helper = [[WebCacheHelper alloc] init];
    });

    return helper;
    }

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Swift1> Swift和OC的区别1.1> Swift没有地址/指针的概念1.2> 泛型1.3> 类型严谨 对...
    cosWriter阅读 13,805评论 1 32
  • UIView+SGFrame.h #import @interface UIView (SGFrame) @pro...
    超越时空的思念_8a22阅读 5,815评论 1 1
  • 1.自定义控件 a.继承某个控件 b.重写initWithFrame方法可以设置一些它的属性 c.在layouts...
    圍繞的城阅读 8,929评论 2 4
  • 1.设计模式是什么? 你知道哪些设计模式,并简要叙述?设计模式是一种编码经验,就是用比较成熟的逻辑去处理某一种类型...
    龍飝阅读 6,595评论 0 12
  • 今天是7月7,传说中七仙女和董永鹊桥相会的日子。 如今,已经是成为了东方的情人节。不过,在中国,这个情人节似乎味道...
    尚香阅读 3,173评论 0 0