我的 iOS 學習小記

啰嗦一句

之前使用的博客系統(tǒng)似乎要停掉了, 自己經(jīng)常會記錄一些易忘記的代碼片段, 還是拷貝到簡書來吧...簡書不支持自動生成大綱目錄啊...這好尷尬...

持續(xù)繼承

Jenkins 中 SVN 由于服務(wù)器時間不一致導(dǎo)致無法更新到最新版本

在鏈接中增加@HEAD
https://xxxxx/項目名稱@HEAD

xib技巧

xib中用 UIColor 設(shè)置邊框顏色

選中xib中的label,在右邊欄的第三個標簽頁中第三項是User Defined Runtime Attributes
添加一個keyPath,keyPath值為layer.borderWidth雏婶,類型為NSNumber留晚,值為你想要設(shè)置的邊框?qū)挾却砦5诙€是設(shè)置邊框的顏色layer.borderColorFromUIColor赋焕,為了兼容CALayer 的KVC 隆判,你得給CALayer增加一個分類

@implementation CALayer (Additions)
- (void)setBorderColorFromUIColor:(UIColor *)color {
  self.borderColor = color.CGColor;
}
@end

在 xib 中添加 xib

在 subview 的 xib 中添加如下代碼和屬性

@property (nonatomic, strong) IBOutlet UIView *view;
- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    if (self = [super initWithCoder:aDecoder]) {
        [self setup];
    }
    return self;
}

- (void)setup {
    
    [[NSBundle mainBundle] loadNibNamed:@"ANScanDrawView" owner:self options:nil];
    [self addSubview:self.view];
    
    [self.view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.bottom.right.equalTo(self);
    }];
}

修改 subview 的 xib 的 file's Owner 為其 Class 并且拖拽 view 屬性.
就可以在 superview 的 xib 中就可以和正常操作一樣添加 subview 了.記得指定 Custom Class.

約束

別擠我

Content Compression Resistance = 不許擠我侨嘀!
這個屬性的優(yōu)先級(Priority)越高飒炎,越不“容易”被壓縮郎汪。也就是說闯狱,當整體的空間裝不下所有的View的時候哄孤,Content Compression Resistance優(yōu)先級越高的瘦陈,顯示的內(nèi)容越完整晨逝。
Content Hugging = 抱緊!
這個屬性的優(yōu)先級越高支鸡,整個View就要越“抱緊”View里面的內(nèi)容。也就是說急前,View的大小不會隨著父級View的擴大而擴大裆针。

topLayoutGuide和bottomLayoutGuide

就是直接使用UILayoutSupport定義的length屬性据块。
這個時候就有個地方要特別注意折剃,在運行到viewDidLoad的時候怕犁,length的值是0奏甫,因為這個時候界面還沒有被繪制阵子,所以一個解決方法就是在ViewController的updateViewConstraints方法里面去使用length值添加約束挠进。如下:

- (void)updateViewConstraints {
    [_topView mas_updateConstraints:^(MASConstraintMaker *make) {
        // 直接利用其length屬性
        make.top.equalTo(self.view.mas_top).with.offset(self.topLayoutGuide.length);
    }];
    [super updateViewConstraints];
}

在Masonry的新版中领突,為UIViewController增加了一個新的Category: MASAdditions君旦,增加了mas_topLayoutGuide和mas_bottomLayoutGuide兩個方法金砍。

自定義baseline

對于自定義的View來說麦锯,baseline默認就是整個view的底部离咐,如果想改變baseline的話,可以重寫UIView的viewForBaselineLayout昆著,返回當成baseline的view即可凑懂。

- (UIView *)viewForBaselineLayout {
    return _imageView;
}

導(dǎo)航欄 TitleView Frame 異常的問題

  • 在自定義titleview 里重寫 intrinsicContentSize 屬性接谨,代碼如下
@property (nonatomic, assign) CGSize intrinsicContentSize;
  • 在賦值到 TitleView 之前指定屬性的 Size 即可.

UITableView

UITableViewStyleGrouped的幾個問題

  • Plain的時候Section的Header和Footer會默認懸停,Grouped不會.
  • 如果用Grouped的話,第一個Section Header會莫名其妙不見,必須使用代理方法返回Section Header的高度,而不能給TableView直接賦值.tableView.sectionHeaderHeight=86;
  • 給TableView的tableFooterView和tableHeaderView指定一個0.01高度的UIView可以消除Grouped多余的頭部和底部的間隙, 直接指定0是不行的.

UINavigationController push 的時候界面卡死的問題

@interface ANNavigationController () <UINavigationControllerDelegate>

@end

@implementation ANNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //  代理
    self.delegate = self;
}

/**
 由控制器控制狀態(tài)欄顏色
 */
- (UIViewController *)childViewControllerForStatusBarStyle{
    return self.topViewController;
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    
    if (self.viewControllers.count > 0) {
        
        viewController.hidesBottomBarWhenPushed = YES;
        /**
         加入全局右滑 POP 功能
         */
        self.interactivePopGestureRecognizer.delegate = nil;
    }
    [super pushViewController:viewController animated:animated];
}

- (void)navigationController:(UINavigationController *)navigationController
       didShowViewController:(UIViewController *)viewController
                    animated:(BOOL)animated {
    if (viewController == navigationController.viewControllers[0]) {
        navigationController.interactivePopGestureRecognizer.enabled = NO;
    } else {
        navigationController.interactivePopGestureRecognizer.enabled = YES;
    }
}

@end

NSString

過濾非法字符

通過巧妙的拆分再合并去除特殊字符

NSCharacterSet *set = [NSCharacterSet characterSetWithCharactersInString:@"\"/\\ <>*|'"];
    NSString *trimmed = [[string componentsSeparatedByCharactersInSet:set] componentsJoinedByString: @""];

Data 的字符串轉(zhuǎn) NSData

- (NSData *)dataWithHexString:(NSString *)hexString {
    NSInteger len = [hexString length];
    char *myBuffer = (char *)malloc(len / 2 + 1);
    bzero(myBuffer, len / 2 + 1);
    for (int i = 0; i < len - 1; i += 2) {
        unsigned int anInt;
        NSString * hexCharStr = [hexString substringWithRange:NSMakeRange(i, 2)];
        NSScanner * scanner = [NSScanner scannerWithString:hexCharStr] ;
        [scanner scanHexInt:&anInt];
        myBuffer[i / 2] = (char)anInt;
    }
    NSData *hexData = [[NSData alloc] initWithBytes:myBuffer length:len/2];
    free(myBuffer);
    return hexData;
}

截取字符串時 emoji 亂碼的問題

因為 emoji 的 length 并不是1, 所以按長度截取 emoji 會出現(xiàn)亂碼問題

if (sender.text.length > kMaxLength) {
        NSRange range = [sender.text rangeOfComposedCharacterSequenceAtIndex:kMaxLength];
        sender.text = [sender.text substringToIndex:range.location];
}

WKWebView

預(yù)覽資源, 如 PDF Excel Word 等.顯示過小, 需要放大怎么辦.


NSString *jScript = @"var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width'); document.getElementsByTagName('head')[0].appendChild(meta);";

    WKUserScript *wkUScript = [[WKUserScript alloc] initWithSource:jScript injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:YES];
    WKUserContentController *wkUController = [[WKUserContentController alloc] init];
    [wkUController addUserScript:wkUScript];
    
    WKWebViewConfiguration *wkWebConfig = [[WKWebViewConfiguration alloc] init];
    wkWebConfig.userContentController = wkUController;
    
    WKWebView *webView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:wkWebConfig];

成長

記錄著自己怎樣進入了 iOS 的世界...

2016-06 學習日記

2016-06-03

  1. LaunchImage : Launch Images Source -> LaunchImage
  2. AppIcon : iOS icon is pre-rendered 不需要系統(tǒng)渲染
  3. 創(chuàng)建窗口和根視圖控制器
  4. 添加子控制器UITableViewController
  5. 自定義TabBarController

2016-06-06

  1. 項目分層
  2. PCH import
  3. 創(chuàng)建UITableViewController子類
  4. 創(chuàng)建UINavigationController并設(shè)置子控制器
  5. 創(chuàng)建UINavigationController的子類,設(shè)置hidesBottomBarWhenPushed

2016-06-07

  1. UINavigationController的UIBarButtonItem的Extension自定義
  2. 攔截push操作實現(xiàn)統(tǒng)一的導(dǎo)航欄按鈕
  3. 設(shè)置整個項目UIBarButtonItem的主題顏色
  4. 根據(jù)是否是DEBUG來控制是否打印日志.
    • (void)initialize 只在第一次使用的時候調(diào)用一次

2016-06-13

  1. 設(shè)置UINavigationBar的主題 背景圖片
  2. [NSMutableDictionary dictionaryWithDictionary:xxx] 字典拷貝
  3. 創(chuàng)建UISearchBar
  4. 用UITextField來 訂制 UISearchBar
  5. 用繼承來實現(xiàn)自定義控件
  6. 繼承UIButton實現(xiàn)文字在左圖標在右的按鈕

2016-06-14

  1. iOS 10 真棒!
  2. 自定義控件,彈出菜單,通過UIButton作為遮罩,加上UIImageView顯示圖片完成.
  3. 代理 Delegate
  4. 擴展UIView, 增加x y centerX centerY width height size屬性,操作簡便
  5. 擴展彈出菜單,以增加功能
  6. 枚舉
  7. 研究UITabBar控件,學會舉一反三,研究復(fù)雜控件結(jié)構(gòu),學會對私有類型進行處理

2016-06-15

  1. 自定義TabBar 遍歷SubViews來修改布局以及增加按鈕
  2. KVC和OC運行時機制來使UITabBarViewController的TabBar替換為我們自定義的TabBar

2016-06-16

  1. work..打包...
  2. 復(fù)習代理,監(jiān)聽TabBar中加號按鈕的點擊事件
  3. 自定義控制器和NavigationViewController initWithRootViewController來進行present和dismiss

2016-06-20

  1. work..打包...
  2. 圖片拉伸的問題
  3. 第一次運行當前版本的判斷 NSUserDefaults [[NSBundle mainBundle].infoDictionary
  4. CFStringRef和NSString之間的相互橋接轉(zhuǎn)換 __bridge
  5. 獲取屏幕寬度
  6. UIScrollView + PageControl制作新特性頁面

2016-06-21

  1. 完善新特性頁面,添加按鈕
  2. 按鈕制作復(fù)選框效果.
  3. 切換根控制器 UIWindow *window = [UIApplication sharedApplication].keyWindow;
  4. OAuth
  5. UIWebView 發(fā)送請求以及 通過代理攔截請求

2016-06-22

  1. AFNetworking 發(fā)送GET/POST請求
  2. MBProgressHUD 顯示loading提示
  3. MJExtension 模型和字典的轉(zhuǎn)換
  4. 了解運行時
  5. plist和Object的歸檔和解檔

2016-06-23

  1. AFNetworking 不支持的Response ContentType在AFURLResponseSerialization.m中找到對應(yīng)的類修改init方法中加載的默認ContentType類型
  2. SDWebImage 異步圖像下載 以及 內(nèi)存警告時候的緩存清理
  3. UITableView 加載數(shù)據(jù)
  4. 大F到手,無心學習了....罪過...

2016-06-24

  1. AFNetworking 監(jiān)聽網(wǎng)絡(luò)狀態(tài)的切換
  2. 自帶的UIRefreshControl實現(xiàn)下拉刷新(繼承自UIControl,通過AddTarget實現(xiàn)操作)

...支撐能力開放平臺項目...

2016-07 學習日記

2016-07-12

  1. 復(fù)習
  2. 延時執(zhí)行代碼
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        // CODE;
});
  1. UILabel的簡單位移動畫,來實現(xiàn)刷出新微博的消息提示
  2. 利用 Xib 自定義一個UIView,實現(xiàn)上拉刷新組件.
  3. 上拉刷新的實現(xiàn)關(guān)于高度計算沒太明白...后續(xù)再看看...
  4. 自定義TextView,實現(xiàn)帶提示文字的功能
  5. 通知,增加通知來監(jiān)聽TextView的文字變化 (dealloc要移除)

2016-07-26

  1. 自定義UIView實現(xiàn)工具條, 按鈕的Tag賦值一個枚舉類型,來區(qū)分不同的按鈕
  2. TextView.alwaysBounceVertical = YES
  3. viewDidAppear中TextView成為第一響應(yīng)者,以便自動彈出鍵盤
  4. 成為TextView代理scrollViewWillBeginDragging方法中,設(shè)置視圖endEditing,關(guān)閉鍵盤

2016-07-27

  1. 代開系統(tǒng)照相機和相冊 來提供一張照片.通過代理實現(xiàn)圖片的獲取,添加到自己定義的UIView中.
  2. 自定義UIView在TextView中顯示圖片.
  3. AFN發(fā)送微博, form-data編碼格式傳送圖片

2016-07-28

  1. 重構(gòu),分層
  2. NSTimer 獲取 未讀消息
  3. TabBarItem 未讀消息的顯示 badgeValue
  4. 應(yīng)用未讀消息的顯示
    [UIApplication sharedApplication].applicationIconBadgeNumber
  5. APP 進入后臺后申請繼續(xù)運行

2016-07-29

  1. 控制 TableView 滾動 (點擊 TabBarItem 觸發(fā)) scrollToRowAtIndexPath

2016-08 學習日記

2016-08-01

  1. 在 iOS 8 之后,設(shè)置應(yīng)用的未讀消息需要申請通知權(quán)限
    float version = [[[UIDevice currentDevice] systemVersion] floatValue];
    if (version >= 8.0) {
        UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge categories:nil];
        [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
        [application registerForRemoteNotifications];
    }
  1. 自定義Cell和Frame, 注意分層減少依賴,以便后期維護.

2016-08-04

  1. 完善 Cell, TableView 的細節(jié)
  2. UILabel 多行,設(shè)置 numberOfLines = 0, 計算高度的時候用
CGSize textMaxSize = CGSizeMake(textMaxWidth, MAXFLOAT);
[text boundingRectWithSize:textMaxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : YXStatusOrginalTextFont} context:nil].size
  1. 對于屬性的轉(zhuǎn)換和處理等, 思考一下 get方法 和 set方法 的合理運用.

2016-08-XX

出差這段時間了解了項目如何開發(fā),了解了 Masonry 的使用. 雖然是在原有的項目上繼續(xù)開發(fā)新需求, 但是還是感覺提升好大...

  1. 我自己斗膽引入 MJExtension , 開發(fā)效率提升很大
  2. 了解了 Masonry 的使用
  3. 了解了一個項目的各 VC (Tabbar, Navi ...)之間的層次關(guān)系
  4. 最重要的一點是多個模塊使用了 TableView, 更深入一點點的了解了 TableView 和自定義 Cell 的使用
  5. 在一些特定的需求中, 我還想到使用了 delegate 來解決, 熟悉了 protocol 的使用
  6. 最后還用了一段時間做了優(yōu)化, 有些 VC 在 pop 之后并沒有調(diào)用 dealloc 方法, 了解了 block 中的循環(huán)引用以及解決方法
    可以使用宏:
#define XYWeakSelf(type)  __weak typeof(type) weak##type = type;
#define XYStrongSelf(type)  __strong typeof(type) type = weak##type;

NavigationController 的右滑 POP 功能

self.navigationController.interactivePopGestureRecognizer.delegate = (id) self;

2016-09 學習日記

2016-09-05

new 和 alloc init 的區(qū)別

[className new]基本等同于[[className alloc] init], 區(qū)別只在于alloc分配內(nèi)存的時候使用了zone.它是給對象分配內(nèi)存的時候堕阔,把關(guān)聯(lián)的對象分配到一個相鄰的內(nèi)存區(qū)域內(nèi)超陆,以便于調(diào)用時消耗很少的代價浦马,提升了程序處理速度.

利用dispatch_once創(chuàng)建單例

void dispatch_once( dispatch_once_t *predicate, dispatch_block_t block);其中第一個參數(shù)predicate捐韩,該參數(shù)是檢查后面第二個參數(shù)所代表的代碼塊是否被調(diào)用的謂詞,第二個參數(shù)則是在整個應(yīng)用程序中只會被調(diào)用一次的代碼塊瞧预。dispach_once函數(shù)中的代碼塊只會被執(zhí)行一次垢油,而且還是線程安全的圆丹。

+ (XYViewController *)sharedInstance {
    static XYViewController *vc;
    static dispatch_once_t one;
    dispatch_once(&one, ^{
        vc = [[self alloc] init];
    });
    return vc;
}

2016-09-06

繼續(xù)看微薄的Demo, 保留一位小數(shù) %.1f
發(fā)現(xiàn) NSString 轉(zhuǎn)換 NSDate 的時候返回 nil , 不知道為什么之前好使, 現(xiàn)在不好使了, 增加了一下 locole 屬性的設(shè)置就好了
    // Tue Sep 06 15:03:00 +0800 2016
    NSDateFormatter *dfm = [[NSDateFormatter alloc] init];
    dfm.dateFormat = @"EEE MMM dd HH:mm:ss Z yyyy";
    // 增加這一行
    dfm.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
    NSDate *createDate = [dfm dateFromString:_created_at];
CGRect 的 坐標系轉(zhuǎn)換
    [view convertRect:(CGRect) toView:(nullable UIView *)];
    [view convertRect:(CGRect) fromView:(nullable UIView *)];

2016-09-22

AVFoundation 實現(xiàn)掃描二維碼
[簡書文章](http://www.reibang.com/p/6b7d54b3f88b)

如果用戶不允許訪問相機. 應(yīng)用會閃退, 加入判斷

        NSString *mediaType = AVMediaTypeVideo;//讀取媒體類型
        AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:mediaType];//讀取設(shè)備授權(quán)狀態(tài)
        if(authStatus == AVAuthorizationStatusRestricted || authStatus == AVAuthorizationStatusDenied){
            //不允許
        }

2016-09-27

提供單例時, 建議私有init方法, 利用如下聲明(.h), 提供一個編譯錯誤:
- (instancetype)init __attribute__((unavailable("Disabled. Use +sharedInstance instead")));

注意: 此時在sharedInstance方法中,需要寫[[self alloc] init]

2016-09-28

打印一堆莫名其妙看不懂的Log

Edit Scheme-> Run -> Arguments, 在Environment Variables里邊添加
OS_ACTIVITY_MODE = Disable

2016-10 學習日記

2016-10-13

突發(fā)奇想用LaunchScreen做載入圖

添加UIImageView.通過添加約束設(shè)置拉伸全屏顯示, 似乎不用提供各種尺寸的LaunchImage.
添加 Storyboard ID. "LaunchScreen"

    UIViewController *viewController = [[UIStoryboard storyboardWithName:@"LaunchScreen" bundle:nil] instantiateViewControllerWithIdentifier:@"LaunchScreen"];
    
    UIView *launchView = viewController.view;

    [UIView animateWithDuration:1.8f delay:0.1f options:UIViewAnimationOptionBeginFromCurrentState animations:^{
        launchView.alpha = 0.0f;
        launchView.layer.transform = CATransform3DScale(CATransform3DIdentity, 1.3f, 1.3f, 1.0f);
    } completion:^(BOOL finished) {
        [launchView removeFromSuperview];
    }];

來為啟動增加動畫, 這里我設(shè)置了延遲 0.1s , 因為還添加了一個label的移動動畫, 如果不延遲的話會明顯感覺有個小卡頓.

2016-10-24

獲取各種目錄
// 獲取沙盒主目錄路徑  
NSString *homeDir = NSHomeDirectory();  
// 獲取Documents目錄路徑  
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);  
NSString *docDir = [paths objectAtIndex:0];  
// 獲取Caches目錄路徑  
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);  
NSString *cachesDir = [paths objectAtIndex:0];  
// 獲取tmp目錄路徑  
NSString *tmpDir =  NSTemporaryDirectory();  

2016-10-26

不知道為什么 Xcode Build 報錯
/Users/hanyuanxu/Library/Developer/Xcode/DerivedData/DiaryForXY-atkiwvdprytfniattjbdfgjreltv/Build/Products/Debug-iphonesimulator/DiaryForXY.app: resource fork, Finder information, or similar detritus not allowed
Command /usr/bin/codesign failed with exit code 1

網(wǎng)上說, 各種證書問題, 刪除創(chuàng)建等等都無果
最后清空DerivedData目錄, 工程目錄下執(zhí)行

xattr -rc .

解決, 并不懂...

2016-10-27

UITableView 的 Style UITableViewStylePlain 和 UITableViewStyleGrouped.

UITableViewStyleGrouped 默認會在 TableView 的 HeaderView 下面增加一條線的間隙, 會在 TableView 的 FooterView 上面增加微寬的間隙.

2016-11 學習日記

2016-11-14

全透明導(dǎo)航欄
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setShadowImage:[UIImage new]];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setShadowImage:nil];
}

還原的這部分放在 viewWillDisappear 好使,但是放在 viewDidDisappear 就不好使
我猜測是因為放在 viewDidDisappear 的時候當頁面沒了才會執(zhí)行.這時候上一個頁面已經(jīng)渲染完了.所以就改不了了.

修改導(dǎo)航欄文字顏色
[self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName:[UIColor blueColor]];
縮放動畫
    view.transform = CGAffineTransformMakeScale(0.01f, 0.01f);//將要顯示的view按照正常比例顯示出來
    [UIView beginAnimations:nil context:UIGraphicsGetCurrentContext()];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 
    [UIView setAnimationDuration:0.8f];//動畫時間
    view.transform=CGAffineTransformMakeScale(1.0f, 1.0f);//先讓要顯示的view最小直至消失
    [UIView commitAnimations]; //啟動動畫

2016-12 學習日記

2016-12-02

原生提供的MD5加密方法

#import <CommonCrypto/CommonDigest.h>

+ (NSString *) md5:(NSString *)str {
    
    const char *cStr = [str UTF8String];
    unsigned char result[CC_MD5_DIGEST_LENGTH];
    
    CC_MD5(cStr, (CC_LONG)strlen(cStr), result);
    
    NSMutableString *ret = [NSMutableString stringWithCapacity:32];
    
    for(int i = 0; i<CC_MD5_DIGEST_LENGTH; i++) {
        [ret appendFormat:@"%02X", result[i]];
    }
    return ret;
}

2016-12-05

GCD 實現(xiàn)線程組,子線程全部結(jié)束后做出響應(yīng).
//  創(chuàng)建線程租
dispatch_group_t group = dispatch_group_create();
//  子線程1
dispatch_group_async(group, dispatch_get_global_queue(0,0), ^{ ... });
//  子線程2
dispatch_group_async(group, dispatch_get_global_queue(0,0), ^{ ... });

dispatch_group_notify(group, dispatch_get_global_queue(0,0), ^{ 
    //  子線程全部執(zhí)行完成后執(zhí)行
    ... 
});

如果線程里面有 block , 想在block結(jié)束后執(zhí)行怎么辦?
可以手動控制線程結(jié)束 :

    //  創(chuàng)建線程租
    dispatch_group_t networking = dispatch_group_create();
    
    //  子線程1
    dispatch_group_enter(networking);
    [A loadData:^(M  *model) {
        ...
        dispatch_group_leave(networking);
    }];

    //  子線程2
    dispatch_group_enter(networking);
    [B loadData:^(M  *model) {
        ...
        dispatch_group_leave(networking);
    }];
    
    dispatch_group_notify(networking,dispatch_get_main_queue(),^{
        // 子線程全部執(zhí)行完成后執(zhí)行    
       ...
    });

2016-12-06

防止CollectionView更新的時候閃屏

CollectionView 更新的時候沒找到帶 Animation 參數(shù)的 暫時找到如下解決辦法

[UIView performWithoutAnimation:^{
    [self.collectionView reloadSections:[NSIndexSet indexSetWithIndex:0]];
}];

2016-12-17

CocoaPods 相關(guān)問題

git clone之后pod install之后打開xcode報錯
大致內(nèi)容就是沒有執(zhí)行 pod install.可是我明明執(zhí)行了..
百度之后說刪除 Pods 目錄 和 現(xiàn)有的 xcworkspace 重新 pod install即可
結(jié)果重新pod install的時候

Generating Pods project
[1]    63036 abort      pod install

報了個錯誤一直沒辦法生成 xcworkspace 文件, 百度也無果.準備重新升級cocoapods

sudo gem install cocoa pods

結(jié)果又報了個錯誤

Operation not permitted - /usr/bin/xcodeproj

百度后執(zhí)行命令

sudo gem install -n /usr/local/bin cocoapods

升級成功,通過

pod COMMAND --version

看到版本號是1.1.1, 執(zhí)行 pod setup 成功后重新 pod install
結(jié)果依然報錯..

Generating Pods project
[1]    63036 abort      pod install

嘗試升級beta版本

sudo gem install -n /usr/local/bin cocoapods --pre

看到版本號是1.2.0beta1, 執(zhí)行 pod setup 成功后重新 pod install

Generating Pods project
Integrating client project
Sending stats
Pod installation complete!

終于成功!猜測是創(chuàng)建工程的人使用了更高版本的CocoaPods.導(dǎo)致我沒辦法兼容.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市责球,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌嘉裤,老刑警劉巖屑宠,帶你破解...
    沈念sama閱讀 218,858評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件侨把,死亡現(xiàn)場離奇詭異妹孙,居然都是意外死亡蠢正,警方通過查閱死者的電腦和手機省店,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,372評論 3 395
  • 文/潘曉璐 我一進店門懦傍,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人说榆,你說我怎么就攤上這事签财∑” “怎么了?”我有些...
    開封第一講書人閱讀 165,282評論 0 356
  • 文/不壞的土叔 我叫張陵神汹,是天一觀的道長。 經(jīng)常有香客問我疼燥,道長蚁堤,這世上最難降的妖魔是什么披诗? 我笑而不...
    開封第一講書人閱讀 58,842評論 1 295
  • 正文 為了忘掉前任呈队,我火速辦了婚禮,結(jié)果婚禮上粒竖,老公的妹妹穿的比我還像新娘几于。我一直安慰自己,他們只是感情好朽砰,可當我...
    茶點故事閱讀 67,857評論 6 392
  • 文/花漫 我一把揭開白布瞧柔。 她就那樣靜靜地躺著睦裳,像睡著了一般。 火紅的嫁衣襯著肌膚如雪哥蔚。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,679評論 1 305
  • 那天,我揣著相機與錄音,去河邊找鬼塌西。 笑死,一個胖子當著我的面吹牛捡需,可吹牛的內(nèi)容都是我干的站辉。 我是一名探鬼主播,決...
    沈念sama閱讀 40,406評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼殊霞,長吁一口氣:“原來是場噩夢啊……” “哼绷蹲!你這毒婦竟也來了顾孽?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,311評論 0 276
  • 序言:老撾萬榮一對情侶失蹤拦英,失蹤者是張志新(化名)和其女友劉穎龄章,沒想到半個月后乞封,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體肃晚,經(jīng)...
    沈念sama閱讀 45,767評論 1 315
  • 正文 獨居荒郊野嶺守林人離奇死亡关串,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,945評論 3 336
  • 正文 我和宋清朗相戀三年晋修,在試婚紗的時候發(fā)現(xiàn)自己被綠了凰盔。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,090評論 1 350
  • 序言:一個原本活蹦亂跳的男人離奇死亡落剪,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出呢堰,到底是詐尸還是另有隱情凡泣,我是刑警寧澤,帶...
    沈念sama閱讀 35,785評論 5 346
  • 正文 年R本政府宣布骂维,位于F島的核電站席舍,受9級特大地震影響哮笆,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜福铅,卻給世界環(huán)境...
    茶點故事閱讀 41,420評論 3 331
  • 文/蒙蒙 一滑黔、第九天 我趴在偏房一處隱蔽的房頂上張望环揽。 院中可真熱鬧,春花似錦汛兜、人聲如沸通今。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,988評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽臼氨。三九已至,卻和暖如春巢寡,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背树叽。 一陣腳步聲響...
    開封第一講書人閱讀 33,101評論 1 271
  • 我被黑心中介騙來泰國打工题诵, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留层皱,地道東北人。 一個月前我還...
    沈念sama閱讀 48,298評論 3 372
  • 正文 我出身青樓草冈,卻偏偏與公主長得像瓮增,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子拳恋,可洞房花燭夜當晚...
    茶點故事閱讀 45,033評論 2 355

推薦閱讀更多精彩內(nèi)容

  • 發(fā)現(xiàn) 關(guān)注 消息 iOS 第三方庫谬运、插件梆暖、知名博客總結(jié) 作者大灰狼的小綿羊哥哥關(guān)注 2017.06.26 09:4...
    肇東周閱讀 12,105評論 4 62
  • Swift版本點擊這里歡迎加入QQ群交流: 594119878最新更新日期:18-09-17 About A cu...
    ylgwhyh閱讀 25,393評論 7 249
  • 生活中怎能缺得了美和愛薛闪?!不能!所以活出自己期待的模樣腊状。
    月心瞳閱讀 79評論 0 0
  • 當一個人心中充滿悲怨時缴挖,周圍的環(huán)境多么美好也無法感受陽光的溫暖焚辅;無論是在萬物復(fù)蘇的季節(jié),還是燈火通明的夜晚同蜻,心中都...
    雪海扁舟閱讀 189評論 0 0