博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
day_01
阅读量:4677 次
发布时间:2019-06-09

本文共 1860 字,大约阅读时间需要 6 分钟。

## 控制台可能会输出以下警告信息

- 警告的原因: [UIImage imageNamed:nil]

```objc

CUICatalog: Invalid asset name supplied: (null)

CUICatalog: Invalid asset name supplied: (null)

```

 

- 警告的原因: [UIImage imageNamed:@""]

```objc

CUICatalog: Invalid asset name supplied:

CUICatalog: Invalid asset name supplied:

```

 

## 准确判断一个字符串是否有内容

```objc

if (string.length) {

 

}

 

/*

错误写法:

if (string) {

 

}

*/

```

 

## 替换UITabBarController内部的tabBar

```objc

// 这里的self是UITabBarController

[self setValue:[[XMGTabBar alloc] init] forKeyPath:@"tabBar"];

```

 

## center和size的设置顺序

- 建议的设置顺序

    - 先设置size

    - 再设置center

 

## 给系统自带的类增加分类

- 建议增加的分类属性名\方法名前面加上前缀, 比如

 

```objc

@interface UIView (XMGExtension)

@property (nonatomic, assign) CGFloat xmg_width;

@property (nonatomic, assign) CGFloat xmg_height;

@property (nonatomic, assign) CGFloat xmg_x;

@property (nonatomic, assign) CGFloat xmg_y;

@property (nonatomic, assign) CGFloat xmg_centerX;

@property (nonatomic, assign) CGFloat xmg_centerY;

 

@property (nonatomic, assign) CGFloat xmg_right;

@property (nonatomic, assign) CGFloat xmg_bottom;

@end

```

 

## 按钮常见的访问方法

```objc

[button imageForState:UIControlStateNormal].size;

button.currentImage.size;

 

[button backgroundImageForState:UIControlStateNormal];

button.currentBackgroundImage;

 

[button titleForState:UIControlStateNormal];

button.currentTitle;

 

[button titleColorForState:UIControlStateNormal];

button.currentTitleColor;

```

 

## 设置按钮的内边距

```objc

@property(nonatomic) UIEdgeInsets contentEdgeInsets UI_APPEARANCE_SELECTOR;

@property(nonatomic) UIEdgeInsets titleEdgeInsets;

@property(nonatomic) UIEdgeInsets imageEdgeInsets;

```

 

## 解决导航控制器pop手势失效

```

self.interactivePopGestureRecognizer.delegate = self;

 

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer

{

    // 手势何时有效 : 当导航控制器的子控制器个数 > 1就有效

    return self.childViewControllers.count > 1;

}

```

 

转载于:https://www.cnblogs.com/finker/p/6535829.html

你可能感兴趣的文章
Aurora — 一个在 MSOffice 内输入 LaTeX 公式的很好用插件
查看>>
关于sql优化的一个小总结
查看>>
Java语言中的正则表达式
查看>>
Java环境变量设置
查看>>
【JBPM4】判断节点decision 方法3 handler
查看>>
filter 过滤器(监听)
查看>>
Linux进程间通信---共享内存
查看>>
Computer Information
查看>>
交换机/路由器上的 S口 F口 E口
查看>>
P1298(矩阵切割)DP
查看>>
wzplayer for delphi demo截图
查看>>
团队第二周:SRS文档
查看>>
Zookeeper的安装与使用:
查看>>
密码策略限制最大与最小长度
查看>>
正则表达式模式
查看>>
使用iframe实现同域跨站提交数据
查看>>
Mouse点击之后,复制GridView控件的数据行
查看>>
ASP.NET开发,从二层至三层,至面向对象 (2)
查看>>
如何查看自己电脑支持OpenGL core版本
查看>>
页面元素定位 XPath 简介
查看>>