這是一篇相當(dāng)于梗顺,我開發(fā)過程中的一篇筆記吧∽荩可能比較雜亂粟誓,是我的第一篇文章。
1.應(yīng)用三方地圖軟件的時(shí)候:地圖功能顯示網(wǎng)格
出現(xiàn)這個(gè)的原因起意,可能是你的地圖apikey有問題鹰服,
2. button 文字對(duì)其
Button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;//左對(duì)齊(UIControlContentHorizontalAlignment、CenterUIControlContentHorizontalAlignmentFill杜恰、UIControlContentHorizontalAlignmentRight)
Button.contentVerticalAlignment = UIControlContentVerticalAlignmentBottom;//底部對(duì)其(UIControlContentVerticalAlignmentCenter、UIControlContentVerticalAlignmentFill仍源、UIControlContentVerticalAlignmentTop)
3設(shè)置button 上圖片心褐,文字的位置
button.imageEdgeInsets = UIEdgeInsetsMake(5,13,21,button.titleLabel.bounds.size.width);//設(shè)置image在button上的位置(上top,左left笼踩,下bottom逗爹,右right)這里可以寫負(fù)值,對(duì)上寫-5,那么image就象上移動(dòng)5個(gè)像素
button.titleEdgeInsets = UIEdgeInsetsMake(71, -button.titleLabel.bounds.size.width-50, 0, 0);//設(shè)置title在button上的位置(上top掘而,左left挟冠,下bottom,右right)
4.向上取整 ceilf()
5斷點(diǎn)續(xù)傳主要方法
/ /. 操作
AFHTTPRequestOperation *op = [[AFHTTPRequestOperation alloc] initWithRequest:request];
_downloadOperation = op;
// 下載
// 指定文件保存路徑袍睡,將文件保存在沙盒中
NSArray docs = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString path = [docs[0] stringByAppendingPathComponent:@“download.zip”];
op.outputStream = [NSOutputStream outputStreamToFileAtPath:path append:NO];
// 設(shè)置下載進(jìn)程代碼塊
bytesRead 當(dāng)前第一次讀取的字節(jié)數(shù)(100k)
totalBytesRead 已經(jīng)下載的字節(jié)數(shù)(4.9M)
totalBytesExpectedToRead 文件總大小(5M)
[op setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {
// 設(shè)置進(jìn)度條百分比
CGFloat precent = (CGFloat)totalBytesRead / totalBytesExpectedToRead;
NSLog(@"%f", precent);
_progressView.progress = precent;
}];
6//主動(dòng)退出程序
- (void)exitApplication {
[UIView beginAnimations:@"exitApplication" context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelegate:self];
// [UIView setAnimationTransition:UIViewAnimationCurveEaseOut forView:self.view.window cache:NO];
[UIView setAnimationTransition:UIViewAnimationCurveEaseOut forView:self.window cache:NO];
[UIView setAnimationDidStopSelector:@selector(animationFinished:finished:context:)];
//self.view.window.bounds = CGRectMake(0, 0, 0, 0);
self.window.bounds = CGRectMake(0, 0, 0, 0);
[UIView commitAnimations];
}
- (void)animationFinished:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
if ([animationID compare:@"exitApplication"] == 0) {
exit(0);
}
}
8設(shè)置tableViewCell間的分割線的顏色
[theTableView setSeparatorColor:[UIColor xxxx ]];
9.SDWebImage 清除圖片緩存
指定的
[[SDImageCache sharedImageCache] removeImageForKey:url];
[[SDImageCache sharedImageCache] removeImageForKey:url fromDisk:YES];
全部
[[SDImageCache sharedImageCache] clearDisk];
[[SDImageCache sharedImageCache] clearMemory];
忽略緩存知染,每次都直接下載方法
? ?UIImage *selectImage = [UIImage imageNamed:[NSString stringWithFormat:@"bottom_profile_active"]];
?? ?self.tabBarController.tabBar.selectedItem.selectedImage? = [selectImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
10.tableView正在滾動(dòng)停止?jié)L動(dòng)
CGPoint offset = self.tableView.contentOffset;
(self.tableView.contentOffset.y > 0) ? offset.y-- : offset.y++;
[self.tableView setContentOffset:offset animated:NO];
另外://在willDisplayCell里面處理數(shù)據(jù)能優(yōu)化tableview的滑動(dòng)流暢性
//獲取所有cell 的方法
NSArray*array = [self.tableView visibleCells];?
11.修改tabbar
設(shè)置文字顏色
[self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor],
設(shè)置位子字體
NSForegroundColorAttributeName, [UIFont systemFontOfSize:18], NSFontAttributeName, nil]];
取到對(duì)應(yīng)nav
UIViewController *vc2 = self.tabBarController.viewControllers[2];
設(shè)置對(duì)應(yīng)圖片
UIImage * homenormalImage = [[UIImage imageNamed:@"bottom_tv_bg"]? imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UIImage * homeselectImage = [[UIImage imageNamed:@"bottom_tv_bg"]? imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
vc2.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"" image:homenormalImage selectedImage:homeselectImage];
設(shè)置文字位置
[self.navigationController.tabBarItem setTitlePositionAdjustment:UIOffsetMake(0, -5)];
設(shè)置圖片位置
self.navigationController.tabBarItem.imageInsets = UIEdgeInsetsMake(-2.5, 0, 2.5, 0);
12.GCD并列請(qǐng)求:
dispatch_group_t serviceGroup = dispatch_group_create();
// Start the first service
dispatch_group_enter(serviceGroup);
[self.configService startWithCompletion:^(ConfigResponse *results, NSError* error){
// Do something with the results
configError = error;
dispatch_group_leave(serviceGroup);
}];
// Start the second service
dispatch_group_enter(serviceGroup);
[self.preferenceService startWithCompletion:^(PreferenceResponse *results, NSError* error){
// Do something with the results
preferenceError = error;
dispatch_group_leave(serviceGroup);
}];
dispatch_group_notify(serviceGroup,dispatch_get_main_queue(),^{
// Assess any errors
NSError *overallError = nil;
if (configError || preferenceError)
{
// Either make a new error or assign one of them to the overall error
overallError = configError ?: preferenceError;
}
// Now call the final completion block
completion(overallError);
});
13.防止 timer? 阻塞
[[NSRunLoop currentRunLoop] addTimer:_animationTimer forMode:UITrackingRunLoopMode];
14.masonry? 等分控件
/**
*? 多個(gè)控件固定間隔的等間隔排列,變化的是控件的長(zhǎng)度或者寬度值
*
*? @param axisType? ? ? ? 軸線方向
*? @param fixedSpacing? ? 間隔大小
*? @param leadSpacing? ? 頭部間隔
*? @param tailSpacing? ? 尾部間隔
*/
- (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType
withFixedSpacing:(CGFloat)fixedSpacing l
eadSpacing:(CGFloat)leadSpacing
tailSpacing:(CGFloat)tailSpacing;
/**
*? 多個(gè)固定大小的控件的等間隔排列,變化的是間隔的空隙
*
*? @param axisType? ? ? ? 軸線方向
*? @param fixedItemLength 每個(gè)控件的固定長(zhǎng)度或者寬度值
*? @param leadSpacing? ? 頭部間隔
*? @param tailSpacing? ? 尾部間隔
*/
- (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType
withFixedItemLength:(CGFloat)fixedItemLength
leadSpacing:(CGFloat)leadSpacing
tailSpacing:(CGFloat)tailSpacing;
15.數(shù)據(jù)遍歷快速斑胜,高效方法
//enumerateObjectsUsingBlock 類似于for控淡,但是比for更快
[array enumerateObjectsUsingBlock:^(MyCell * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
[obj cellOffset];
}];
16.runtime 或者屬性
// 獲取對(duì)象里的屬性列表
objc_property_t * properties = class_copyPropertyList([instance
class], &outCount);
for (i = 0; i < outCount; i++) {
objc_property_t property =properties[i];
//? 屬性名轉(zhuǎn)成字符串
NSString *propertyName = [[NSString alloc] initWithCString:property_getName(property) encoding:NSUTF8StringEncoding];
// 判斷該屬性是否存在
if ([propertyName isEqualToString:verifyPropertyName]) {
free(properties);
return YES;
}
}
free(properties);
17.如何獲取app? 網(wǎng)頁JS代碼? command+,? 進(jìn)入偏好設(shè)置止潘,? 高級(jí)打開菜單欄掺炭,然后safafi 開發(fā)-simulate-選擇你想要的。
18.一些干貨推薦
(1)圖片大全
http://findicons.com/
http://www.easyicon.net/
(2)大牛blog
博客地址 RSS地址
OneV's Den http://onevcat.com/atom.xml
破船之家 http://beyondvincent.com/atom.xml
NSHipster http://nshipster.cn/feed.xml
Limboy 無網(wǎng)不剩 http://feeds.feedburner.com/lzyy
唐巧的技術(shù)博客 http://blog.devtang.com/atom.xml
Lex Tang http://lexrus.com/feed.xml
念茜的博客 http://nianxi.net/feed.xml
Xcode Dev http://blog.xcodev.com/atom.xml
Ted's Homepage http://wufawei.com/feed
txx's blog http://blog.t-xx.me/atom.xml
Kevin Blog http://zhowkev.in/rss
阿毛的蛋疼地 http://www.xiangwangfeng.com/atom.xml
亞慶的 Blog http://billwang1990.github.io/atom.xml
Nonomori http://nonomori.farbox.com/feed
言無不盡 http://tang3w.com/atom.xml
Wonderffee's Blog http://wonderffee.github.io/atom.xml
I'm TualatriX http://imtx.me/feed/latest/
Cocoabit http://blog.cocoabit.com/atom.xml
nixzhu on scriptogr.am http://nixzhu.me/feed
不會(huì)開機(jī)的男孩 http://studentdeng.github.io/atom.xml
Nico http://blog.inico.me/atom.xml
阿峰的技術(shù)窩窩 http://hufeng825.github.io/atom.xml
answer_huang http://answerhuang.duapp.com/index.php/feed/
webfrogs http://blog.nswebfrog.com/feed/
代碼手工藝人 http://joeyio.com/atom.xml
Lancy's Blog http://gracelancy.com/atom.xml
I'm Allen http://www.imallen.com/atom.xml
Travis' Blog http://imi.im/feed
王中周的技術(shù)博客 http://wangzz.github.io/atom.xml
會(huì)寫代碼的豬 http://gaosboy.com/feed/atom/
克偉的博客 http://feed.cnblogs.com/blog/u/23857/rss
搖滾詩人 http://feed.cnblogs.com/blog/u/35410/rss
Luke's Homepage http://geeklu.com/feed/
蕭宸宇 http://iiiyu.com/atom.xml
Yuan博客 http://www.heyuan110.com/?feed=rss2
Shining IO http://shiningio.com/atom.xml
YIFEIYANG--易飛揚(yáng)的博客 http://www.yifeiyang.net/feed
KooFrank's Blog http://koofrank.com/rss
hello it works http://helloitworks.com/feed
碼農(nóng)人生 http://msching.github.io/atom.xml
玉令天下的Blog http://yulingtianxia.com/atom.xml
不掏蜂窩的熊 http://www.hotobear.com/?feed=rss2
貓·仁波切 https://andelf.github.io/atom.xml
煲仔飯 http://ivoryxiong.org/feed.xml
里脊串的開發(fā)隨筆 http://adad184.com/atom.xml
Chun Tips http://chun.tips/atom.xml
Why's blog - 汪海的實(shí)驗(yàn)室 http://blog.callmewhy.com/atom.xml
Kenshin Cui's Blog http://www.cnblogs.com/kenshincui/rss
技術(shù)哥的博客 http://suenblog.duapp.com/rss/
(3)很多優(yōu)秀的第三方庫
http://blog.csdn.net/yipanbo/article/details/40047735
(4)swift 學(xué)習(xí)
http://wiki.jikexueyuan.com/project/swift/
http://www.ioscookies.com? 三方插件
19 tableViewCell ?
UITableViewCell分割線左邊部分缺少一些的解決方法
-(void)viewDidLayoutSubviews {
if ([self.mytableview respondsToSelector:@selector(setSeparatorInset:)]) {
[self.mytableview setSeparatorInset:UIEdgeInsetsZero];
}
if ([self.mytableview respondsToSelector:@selector(setLayoutMargins:)])? {
[self.mytableview setLayoutMargins:UIEdgeInsetsZero];
}
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPat{
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setSeparatorInset:)]){
[cell setSeparatorInset:UIEdgeInsetsZero];
}
}
20 UIButton怎樣去掉高亮透明效果
- (void)setHighlighted:(BOOL)highlighted{
}
self.btn_loginNow.adjustsImageWhenDisabled = NO;
self.btn_loginNow.adjustsImageWhenHighlighted = NO;
21 報(bào)錯(cuò)clang
這個(gè)錯(cuò)誤一定是有重復(fù)的類凭戴,或者屬性 比如使用了 const