- 但凡以view開頭的方法,先調(diào)用super方法
- 方法有File蟀给,必須用到路徑
[[NSBundle mainBundle] pathForResource:imageName ofType:@"png"];
- 除開圖片之外的其他資源,都用
mainBundle
- 獲取
1到x之間
的整數(shù):int value = (arc4random() % x) + 1;
arc4random_uniform(100)
生成0~100之間的隨機整數(shù)蜂嗽。 - 字符串創(chuàng)建控制器忧侧,不用import頭文件
[[NSClassFromString(@"homeVC") alloc] init];
- 輸出兩位的數(shù)字 不夠時用0補齊
NSLog(@"%02d" ,1); → 01
- 一個像素尺寸的圖片
1 / [UIScreen mainScreen].scale
- 修改Tabbar Item的屬性
// 修改標題位置
self.tabBarItem.titlePositionAdjustment = UIOffsetMake(0, -10);
// 修改圖片位置
self.tabBarItem.imageInsets = UIEdgeInsetsMake(-3, 0, 3, 0);
// 批量修改屬性
for (UIBarItem *item in self.tabBarController.tabBar.items) {
[item setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont fontWithName:@"Helvetica" size:19.0], NSFontAttributeName, nil]
forState:UIControlStateNormal];
}
// 設(shè)置選中和未選中字體顏色
[[UITabBar appearance] setShadowImage:[[UIImage alloc] init]];
//未選中字體顏色
[[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor greenColor]} forState:UIControlStateNormal];
//選中字體顏色
[[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor cyanColor]} forState:UIControlStateSelected];
-
MJExtension
字典轉(zhuǎn)模型
// 模型屬性名和字典中的key有沖突時時替換
+ (NSDictionary *)mj_replacedKeyFromPropertyName
{
return @{
@"Id" : @"id",
@"desc" : @"desciption",
@"oldName" : @"name.oldName",
@"nowName" : @"name.newName",
@"nameChangedTime" : @"name.info[1].nameChangedTime",
@"bag" : @"other.bag"
};
}
// 屬性里的數(shù)組類型
@property(nonatomic, strong) NSArray * users;
+ (NSDictionary *)mj_objectClassInArray
{
return @{
@"users":@"User",// 或者
// @"users":[User class],
};
}
- 打包發(fā)布
-
Edit Scheme
→run狀態(tài)下設(shè)置Release模式
- 模擬器一定選
真機
-
comm+B
編譯标捺,Products文件下的app紅色變黑色,找到它 - 拷貝到
Payload
文件夾乎完,壓縮成zip - 后綴名zip改為
ipa
-
直接把app拖到在iTunes的
應(yīng)用程序
界面熏兄,找到它就打包好了
- 添加東西到項目,先
comm+B
一下看有沒有錯
一個cell對應(yīng)一個xib树姨,不管有多么相同
plist文件名不要包含Info
給控制器傳遞數(shù)據(jù)霍弹,不能在重寫模型的方法里,他先執(zhí)行娃弓,別的還沒創(chuàng)建
——直接用模型
把照片存到相冊中:
(1)UIImageWriteToSavedPhotosAlbum(image, nil , nil , nil );
不需要回調(diào)典格,上下文也不需要傳
涉及到隱私,會提示
(2)沒有名稱台丛,又不好去取出來耍缴?
使用圖片選擇器UIImagePickerController,實現(xiàn)代理方法
挽霉?防嗡?寫到沙盒
- 把照片保存到模擬器相冊
-(void)viewDidLoad {
[super viewDidLoad];
for (int index=1; index<11; index++) {
NSString *imgName=[NSString stringWithFormat:@"%d.jpg", index];
UIImage *img=[UIImage imageNamed:imgName];
UIImageWriteToSavedPhotosAlbum(img, nil, nil, nil);
}
}
開發(fā)常識
狀態(tài)欄高度:20
導航欄高度:44
cell的默認高度:44
UITabBar默認高度:49
高度64這樣寫死了好不好?如果是橫屏的話侠坎,有可能是44
navigationBar豎屏下默認高度44蚁趁,橫屏下默認高度32
屏幕尺寸
1.屏幕大小
iPhone4做原型時,320×480
iPhone5做原型時实胸,320×568
iPhone6做原型時他嫡,375×667
iPhone6Plus原型,414×736
2.屏幕分辨率
iPhone4的顯示分辨率庐完,640×960
iPhone5的顯示分辨率钢属,640×1136
iPhone6的顯示分辨率,1334×750
iPhone6 Plus顯示為门躯,1920×1080
頁面不添加標記進行一次性判斷
if (objc_getAssociatedObject(self, _cmd)) {
NSLog(@"已經(jīng)加載過啦");
} else {
objc_setAssociatedObject(self, _cmd, @"Launch", OBJC_ASSOCIATION_RETAIN);
NSLog(@"第一次加載");
}