1. 從iOS9開始的常見報(bào)錯(cuò)
objc Application windows are expected to have a root view controller at the end of application launch
- 從iOS9開始, 在程序啟動(dòng)完畢那一刻顯示出來的窗口必須要設(shè)置根控制器(在程序啟動(dòng)完成后,在顯示窗口則可以不設(shè)置根控制器)
2.應(yīng)用程序的圖標(biāo)
舊項(xiàng)目中的圖標(biāo)只要符合1個(gè)條件即可
圖片名叫做Icon.png
3.有些圖片顯示出來會(huì)自動(dòng)渲染成藍(lán)色
比如:
設(shè)置tabBarItem的選中圖片
bjc vc.tabBarItem.selectedImage = image;
設(shè)置UIButtonTypeSystem樣式按鈕的image時(shí)
[btn setImage:image forState:UIControlStateNormal];```
### 4.tabarItem按鈕選中時(shí),圖片會(huì)被系統(tǒng)渲染的解決方案:
- 4.1 再次產(chǎn)生一張不會(huì)進(jìn)行渲染的圖片
```objc
// 加載圖片
UIImage *tempImage = [UIImage imageNamed:@"tabBar_essence_click_icon"];
// 產(chǎn)生一張不會(huì)進(jìn)行自動(dòng)渲染的圖片
UIImage *selectedImage = [tempImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
vc.tabBarItem.selectedImage = selectedImage;
-
4.2 直接在xcassets文件中配置
Snip20151105_1.png
5.設(shè)置TabBarItem的文字屬性
直接設(shè)置每一個(gè)tabBarItem對(duì)象
// 普通狀態(tài)下的文字屬性
NSMutableDictionary *normalAttrs = [NSMutableDictionary dictionary];
normalAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:14];
normalAttrs[NSForegroundColorAttributeName] = [UIColor grayColor]; [vc.tabBarItem setTitleTextAttributes:normalAttrs forState:UIControlStateNormal];
// 選中狀態(tài)下的文字屬性
NSMutableDictionary *selectedAttrs = [NSMutableDictionary dictionary];
selectedAttrs[NSForegroundColorAttributeName] = [UIColor darkGrayColor];
[vc.tabBarItem setTitleTextAttributes:selectedAttrs forState:UIControlStateSelected];
// 字典中用到的key 1.iOS7之前(在UIStringDrawing.h中可以找到) - 比如UITextAttributeFont\UITextAttributeTextColor - 規(guī)律:UITextAttributeXXX
- iOS7開始(在NSAttributedString.h中可以找到)
比如:
NSFontAttributeName\NSForegroundColorAttributeName - 規(guī)律:NSXXXAttributeName ```
6. 通過UITabBarItem的appearance對(duì)象統(tǒng)一設(shè)置
/**** 設(shè)置所有UITabBarItem的文字屬性 ****/
UITabBarItem *item = [UITabBarItem appearance];
// 普通狀態(tài)下的文字屬性
NSMutableDictionary *normalAttrs = [NSMutableDictionary dictionary];
normalAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:14];
normalAttrs[NSForegroundColorAttributeName] = [UIColor grayColor];
[item setTitleTextAttributes:normalAttrs forState:UIControlStateNormal];
// 選中狀態(tài)下的文字屬性
NSMutableDictionary *selectedAttrs = [NSMutableDictionary dictionary];
selectedAttrs[NSForegroundColorAttributeName] = [UIColor darkGrayColor];
[item setTitleTextAttributes:normalAttrs forState:UIControlStateSelected];
7.項(xiàng)目的圖片資源
- 可以利用一個(gè)Mac軟件解壓(解壓ipa或者car文件里的資源,特別是圖片資源)
https://github.com/devcxm/iOS-Images-Extractor
8.顏色相關(guān)的一些知識(shí)
8.1顏色的基本組成
一種顏色由N個(gè)顏色通道組成
顏色通道
1個(gè)顏色通道占據(jù)8bit
1個(gè)顏色通道的取值范圍
10進(jìn)制 : [0, 255]
16進(jìn)制 : [00, ff];常見的顏色通道
紅色 red R
綠色 green G
藍(lán)色 blue B
透明度 alpha A
R\G\B一樣的是灰色
8.2顏色的種類
- 24bit顏色
由R\G\B組成的顏色
常見的表示形式
10進(jìn)制(僅僅是用在CSS)
紅色 : rgb(255,0,0)
綠色 : rgb(0,255,0)
藍(lán)色 : rgb(0,0,255)
黃色 : rgb(255,255,0)
黑色 : rgb(0,0,0)
白色 : rgb(255,255,255)
灰色 : rgb(80,80,80)
16進(jìn)制(可以用在CSS\android)
紅色 : #ff0000 #f00
綠色 : #00ff00 #0f0
藍(lán)色 : #0000ff #00f
黃色 : #ffff00 #ff0
黑色 : #000000 #000
白色 : #ffffff #fff
灰色 : #979797
- 32bit顏色
由R\G\B\A組成的顏色
常見的表示形式
10進(jìn)制(僅僅是用在CSS)
紅色 : rgba(255,0,0,255)
綠色 : rgba(0,255,0,255)
藍(lán)色 : rgba(0,0,255,255)
黃色 : rgba(255,255,0,255)
黑色 : rgba(0,0,0,255)
白色 : rgba(255,255,255,255)
16進(jìn)制(#AARRGGBB, 僅僅是用在android)
紅色 : #ffff0000
綠色 : #ff00ff00
藍(lán)色 : #ff0000ff
黃色 : #ffffff00
黑色 : #ff000000
白色 : #ffffffff
9.PCH文件可能引發(fā)的錯(cuò)誤
(報(bào)錯(cuò)原因: 將pch文件的內(nèi)容拷貝到非OC源代碼中,如: c語言文件)

- 解決方案
ifndef PrefixHeader_pch
define PrefixHeader_pch
/ 如果希望某些內(nèi)容能拷貝到任何源代碼文件(OC\C\C++等), 那么就不要寫在#ifdef OBJC和#endif之間 /
/ 在#ifdef OBJC和#endif之間的內(nèi)容, 只會(huì)拷貝到OC源代碼文件中, 不會(huì)拷貝到其他語言的源代碼文件中 /
ifdef OBJC
endif
/ 在#ifdef OBJC和#endif之間的內(nèi)容, 只會(huì)拷貝到OC源代碼文件中, 不會(huì)拷貝到其他語言的源代碼文件中 /
endif
10.在Build Setting中配置宏
- 如果項(xiàng)目中有些宏找不到, 可能是配置在Build Setting中(如:command + 點(diǎn)擊, 未能跳入該宏定義文件,就可能在:Preprocessing中的Proprocessor Macros定義了該宏, 編譯前宏定義, 在這里可以在調(diào)試和發(fā)布兩種情況下,定義不同值的宏)

注意點(diǎn):宏的名字不能全部都是小寫字母(加數(shù)字,或者變?yōu)榇髮懚伎梢?
-
如果宏的名字全部是小寫, 會(huì)出現(xiàn)以下錯(cuò)誤:
Snip20151105_10.png 宏定義的中,參數(shù)都要用"( )"括住,不然會(huì)出問題
11.Appearance的使用場(chǎng)合
- 只要后面帶有
UI_APPEARANCE_SELECTOR的方法或者屬性,都可以通過appearance對(duì)象統(tǒng)一設(shè)置 - 比如
@interface UISwitch : UIControl <NSCoding>
@property(nullable, nonatomic, strong) UIColor *onTintColor NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
@end
UISwitch *s = [UISwitch appearance];
s.onTintColor = [UIColor redColor];
12.其他配置項(xiàng)目時(shí)需要注意的問題
創(chuàng)建項(xiàng)目時(shí)要勾選git管理, 每次開始項(xiàng)目時(shí),提交一下git,下次查看項(xiàng)目時(shí),著重看add和modify部分
創(chuàng)建項(xiàng)目時(shí)根據(jù)需要勾選UITesting(慕課網(wǎng)上有具體的介紹: http://www.imooc.com/learn/560)
配置好類前綴
選擇好使用啟動(dòng)圖片還是lauchScreen
使用人為warning
#warning 這是人為warning
廢棄的方法是指蘋果不推薦使用,不是指方法不能用
如果控制器之間有繼承關(guān)系,則不建議使用Storyboard,因?yàn)镾toryboard中的部分控件是不能被繼承到
在Scheme中選擇Debug和Release模式,可以測(cè)試在兩種模式下打印的情況,可通過宏定義將Release模式下的打印都替換成空,減少Release模式的性能消耗

