1.切換根視圖控制器淡出的效果(切換成登陸頁面之類的)
self.window.rootViewController = loginVC;
[UIView transitionWithView:self.window
duration:0.5
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^ { self.window.rootViewController = loginVC; }
completion:nil];
2.一個(gè)viewcontroller 包含多個(gè)viewcontroller(可用在切換頁面上)
[self addChildViewController:self.cv1];
[self addChildViewController:self.vc2];
self.currentViewController = self.vc1;
[self.view addSubview:self.vc1.view];
然后在切換的時(shí)候用下面方法
[self transitionFromViewController:self.currentViewController toViewController:self.equipmentListVC duration:0 options:UIViewAnimationOptionTransitionNone animations:^{
} completion:^(BOOL finished) {
[self.view addSubview:self.equipmentListVC.view];
self.currentViewController = self.equipmentListVC;
}];
這個(gè)方法可以用于在給vc瘦身上猎贴,分出多個(gè)子視圖控制器,可讀性也會(huì)比較好吨枉。
3.圖片不能有alpha 通道
上架App過程中,在上傳預(yù)覽圖咸这、圖標(biāo)的時(shí)候焰枢,提示:如果圖片有問題王财,頁面上會(huì)提示“圖片不能有alpha 通道忆矛〔於祝”
解決方案:打開finder,找到圖片催训,顯示簡介洽议,這里可以看到圖片是否帶有alpha通道;
用mac自帶的預(yù)覽打開圖片漫拭,選擇導(dǎo)出亚兄,這里可以渲染是否帶alpha通道;
4.在任意頁面讓鍵盤消失掉
[[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil];
5.數(shù)組內(nèi)查找(數(shù)組包含是字典或?qū)ο蠖伎梢裕?/p>
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name == %@", "張三"];
NSArray *filteredArray = [array filteredArrayUsingPredicate:predicate];
6.數(shù)組排序
7.快速設(shè)置頁面搭建
使用storyboard的靜態(tài)tableview
8.設(shè)置label的行間距(文字樣式什么的建議用NSMutableAttributedString)
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:self.contentLabel.text];
NSMutableParagraphStyle *paragraphStyle =? [[NSMutableParagraphStyle alloc] init];? ?
[paragraphStyle setLineSpacing:3];?
? //調(diào)整行間距? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle? ? ? ? ? ? ? ? ? ? ? ? ? range:NSMakeRange(0, [self.contentLabel.text length])];
self.contentLabel.attributedText = attributedString;
9.快速設(shè)置tableview的分割線距離
self.table.separatorInset = UIEdgeInsetsMake(0, 10, 0, 0);
10.去掉多余的分割線
self.table.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];