啰嗦一句
之前使用的博客系統(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
- LaunchImage : Launch Images Source -> LaunchImage
- AppIcon : iOS icon is pre-rendered 不需要系統(tǒng)渲染
- 創(chuàng)建窗口和根視圖控制器
- 添加子控制器UITableViewController
- 自定義TabBarController
2016-06-06
- 項目分層
- PCH import
- 創(chuàng)建UITableViewController子類
- 創(chuàng)建UINavigationController并設(shè)置子控制器
- 創(chuàng)建UINavigationController的子類,設(shè)置hidesBottomBarWhenPushed
2016-06-07
- UINavigationController的UIBarButtonItem的Extension自定義
- 攔截push操作實現(xiàn)統(tǒng)一的導(dǎo)航欄按鈕
- 設(shè)置整個項目UIBarButtonItem的主題顏色
- 根據(jù)是否是DEBUG來控制是否打印日志.
- (void)initialize 只在第一次使用的時候調(diào)用一次
2016-06-13
- 設(shè)置UINavigationBar的主題 背景圖片
- [NSMutableDictionary dictionaryWithDictionary:xxx] 字典拷貝
- 創(chuàng)建UISearchBar
- 用UITextField來 訂制 UISearchBar
- 用繼承來實現(xiàn)自定義控件
- 繼承UIButton實現(xiàn)文字在左圖標在右的按鈕
2016-06-14
- iOS 10 真棒!
- 自定義控件,彈出菜單,通過UIButton作為遮罩,加上UIImageView顯示圖片完成.
- 代理 Delegate
- 擴展UIView, 增加x y centerX centerY width height size屬性,操作簡便
- 擴展彈出菜單,以增加功能
- 枚舉
- 研究UITabBar控件,學會舉一反三,研究復(fù)雜控件結(jié)構(gòu),學會對私有類型進行處理
2016-06-15
- 自定義TabBar 遍歷SubViews來修改布局以及增加按鈕
- KVC和OC運行時機制來使UITabBarViewController的TabBar替換為我們自定義的TabBar
2016-06-16
- work..打包...
- 復(fù)習代理,監(jiān)聽TabBar中加號按鈕的點擊事件
- 自定義控制器和NavigationViewController initWithRootViewController來進行present和dismiss
2016-06-20
- work..打包...
- 圖片拉伸的問題
- 第一次運行當前版本的判斷 NSUserDefaults [[NSBundle mainBundle].infoDictionary
- CFStringRef和NSString之間的相互橋接轉(zhuǎn)換 __bridge
- 獲取屏幕寬度
- UIScrollView + PageControl制作新特性頁面
2016-06-21
- 完善新特性頁面,添加按鈕
- 按鈕制作復(fù)選框效果.
- 切換根控制器 UIWindow *window = [UIApplication sharedApplication].keyWindow;
- OAuth
- UIWebView 發(fā)送請求以及 通過代理攔截請求
2016-06-22
- AFNetworking 發(fā)送GET/POST請求
- MBProgressHUD 顯示loading提示
- MJExtension 模型和字典的轉(zhuǎn)換
- 了解運行時
- plist和Object的歸檔和解檔
2016-06-23
- AFNetworking 不支持的Response ContentType在AFURLResponseSerialization.m中找到對應(yīng)的類修改init方法中加載的默認ContentType類型
- SDWebImage 異步圖像下載 以及 內(nèi)存警告時候的緩存清理
- UITableView 加載數(shù)據(jù)
- 大F到手,無心學習了....罪過...
2016-06-24
- AFNetworking 監(jiān)聽網(wǎng)絡(luò)狀態(tài)的切換
- 自帶的UIRefreshControl實現(xiàn)下拉刷新(繼承自UIControl,通過AddTarget實現(xiàn)操作)
...支撐能力開放平臺項目...
2016-07 學習日記
2016-07-12
- 復(fù)習
- 延時執(zhí)行代碼
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// CODE;
});
- UILabel的簡單位移動畫,來實現(xiàn)刷出新微博的消息提示
- 利用 Xib 自定義一個UIView,實現(xiàn)上拉刷新組件.
- 上拉刷新的實現(xiàn)關(guān)于高度計算沒太明白...后續(xù)再看看...
- 自定義TextView,實現(xiàn)帶提示文字的功能
- 通知,增加通知來監(jiān)聽TextView的文字變化 (dealloc要移除)
2016-07-26
- 自定義UIView實現(xiàn)工具條, 按鈕的Tag賦值一個枚舉類型,來區(qū)分不同的按鈕
- TextView.alwaysBounceVertical = YES
- viewDidAppear中TextView成為第一響應(yīng)者,以便自動彈出鍵盤
- 成為TextView代理scrollViewWillBeginDragging方法中,設(shè)置視圖endEditing,關(guān)閉鍵盤
2016-07-27
- 代開系統(tǒng)照相機和相冊 來提供一張照片.通過代理實現(xiàn)圖片的獲取,添加到自己定義的UIView中.
- 自定義UIView在TextView中顯示圖片.
- AFN發(fā)送微博, form-data編碼格式傳送圖片
2016-07-28
- 重構(gòu),分層
- NSTimer 獲取 未讀消息
- TabBarItem 未讀消息的顯示 badgeValue
- 應(yīng)用未讀消息的顯示
[UIApplication sharedApplication].applicationIconBadgeNumber
- APP 進入后臺后申請繼續(xù)運行
2016-07-29
- 控制 TableView 滾動 (點擊 TabBarItem 觸發(fā)) scrollToRowAtIndexPath
2016-08 學習日記
2016-08-01
- 在 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];
}
- 自定義Cell和Frame, 注意分層減少依賴,以便后期維護.
2016-08-04
- 完善 Cell, TableView 的細節(jié)
- UILabel 多行,設(shè)置 numberOfLines = 0, 計算高度的時候用
CGSize textMaxSize = CGSizeMake(textMaxWidth, MAXFLOAT);
[text boundingRectWithSize:textMaxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : YXStatusOrginalTextFont} context:nil].size
- 對于屬性的轉(zhuǎn)換和處理等, 思考一下 get方法 和 set方法 的合理運用.
2016-08-XX
出差這段時間了解了項目如何開發(fā),了解了 Masonry 的使用. 雖然是在原有的項目上繼續(xù)開發(fā)新需求, 但是還是感覺提升好大...
- 我自己斗膽引入 MJExtension , 開發(fā)效率提升很大
- 了解了 Masonry 的使用
- 了解了一個項目的各 VC (Tabbar, Navi ...)之間的層次關(guān)系
- 最重要的一點是多個模塊使用了 TableView, 更深入一點點的了解了 TableView 和自定義 Cell 的使用
- 在一些特定的需求中, 我還想到使用了 delegate 來解決, 熟悉了 protocol 的使用
- 最后還用了一段時間做了優(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 上面增加微寬的間隙.
- Reveal 使用方法 點這里
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)致我沒辦法兼容.