1.Terminating app due to uncaught exception 'NSUnknownKeyException', reason
網(wǎng)上搜了一大堆恰聘,都是說XIB的關(guān)聯(lián)問題,我把xib文件刪除了連接,重新連了一下商膊,還是報(bào)錯(cuò)类嗤。后來發(fā)現(xiàn)是我的代碼問題裂七。
NSMutableDictionary *dict = (NSMutableDictionary *)array.lastObject;
[dict setValue:textString forKey:@"limit"];
array.lastObject不是可變字典褥符,這里我把它強(qiáng)轉(zhuǎn)了,導(dǎo)致
[dict setValue:textString forKey:@"limit"];報(bào)錯(cuò)韭寸。
用 NSDictionary 就可以了春哨。
2. 重新安裝xcode cocoapods出現(xiàn)
Unable to download data from https://gems.ruby-china.org/ - bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)```, 即執(zhí)行``` sudo gem install cocoapods
出現(xiàn)的錯(cuò)
執(zhí)行 sudo -i
, 進(jìn)入到 root 去執(zhí)行 該命令
sudo -i
在去執(zhí)行
sudo gem install cocoapods
結(jié)果為
Successfully installed cocoapods-1.6.1
Parsing documentation for cocoapods-1.6.1
Done installing documentation for cocoapods after 2 seconds
1 gem installed
退出root, 重新打開一個(gè)窗口恩伺,執(zhí)行 pod --version
赴背,查看版本,但是現(xiàn)在又報(bào)錯(cuò)了
Ignoring executable-hooks-1.4.2 because its extensions are not built. Try: gem pristine executable-hooks --version 1.4.2
Ignoring gem-wrappers-1.3.2 because its extensions are not built. Try: gem pristine gem-wrappers --version 1.3.2
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems.rb:241:in `bin_path': can't find gem cocoapods (>= 0.a) (Gem::GemNotFoundException)
from /usr/local/bin/pod:22:in `<main>'
接著刪除了gem ,清除所有包舊版本晶渠,保留最新版
gem cleanup
結(jié)果為
Cleaning up installed gems...
Clean Up Complete
查看gem版本
gem update
結(jié)果為
2.6.14
接著執(zhí)行
gem update
又報(bào)錯(cuò)了
Updating installed gems
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)
解決辦法:
先后執(zhí)行下面2行代碼:
sudo gem sources -r https://rubygems.org
結(jié)果為:
Password:
source https://rubygems.org not present in cache
sudo gem sources -a http://rubygems.org
結(jié)果為:
https://rubygems.org is recommended for security over http://rubygems.org
Do you want to add this insecure source? [yn] y
http://rubygems.org added to sources
就可以正常安裝了
執(zhí)行
sudo gem install cocoapods
結(jié)果為:
………………(代表還有很多命令)
Parsing documentation for molinillo-0.6.6
Installing ri documentation for molinillo-0.6.6
Parsing documentation for atomos-0.1.3
Installing ri documentation for atomos-0.1.3
Parsing documentation for nanaimo-0.2.6
Installing ri documentation for nanaimo-0.2.6
Parsing documentation for xcodeproj-1.8.1
Installing ri documentation for xcodeproj-1.8.1
Parsing documentation for fourflusher-2.2.0
Installing ri documentation for fourflusher-2.2.0
Parsing documentation for ruby-macho-1.4.0
Installing ri documentation for ruby-macho-1.4.0
Parsing documentation for cocoapods-1.6.1
Installing ri documentation for cocoapods-1.6.1
Done installing documentation for cocoapods-core, cocoapods-downloader, cocoapods-trunk, molinillo, atomos, nanaimo, xcodeproj, fourflusher, ruby-macho, cocoapods after 9 seconds
WARNING: Unable to pull data from 'https://gems.ruby-china.org/': bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)
10 gems installed
3. 更新cocoaPods凰荚,執(zhí)行命令 sudo gem update --system .出現(xiàn)了錯(cuò)誤: ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError); bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)
原來是cocoapods更新了褒脯,本來是1.6.0便瑟,執(zhí)行了下面命令更新pod之后,版本變?yōu)?.7.0.beta.3
sudo gem install -n /usr/local/bin cocoapods --pre
再去執(zhí)行一些命令就好了
4. ld: framework not found Pods__________ clang: error: linker command failed with exit code 1 (use -v to see invocation)
出現(xiàn)這個(gè)問題番川,把Build Settings
---->的 Other Linker Flags
里面的所有庫都刪除了胳徽,就只剩下了第二個(gè)圖里面的
然后把
Build Phases
的Linker Binary With Libraries
刪除不存在(顯示為顏色灰白)的庫在command +shift +k, 清空一下,重新運(yùn)行爽彤,即可了
5. ld: library not found for -lstdc++.6.0.9 , clang: error: linker command failed with exit code 1 (use -v to see invocation)
多數(shù)情況下是文件路徑配置問題
在Building Phases
下面的 Link Binary With Libraries
把這個(gè)庫show In Finder, 發(fā)現(xiàn)并不是在工程里路徑下,重新把它拖到了工程目錄里面缚陷,就好了适篙。
6. Could not insert new outlet connection, could not find any information for the class named DemoViewController
把DemoViewController.h 和 DemoViewController.m 先show In finder, 拷貝出來,在工程里面刪除箫爷,重新添加就好了
7. cell復(fù)用問題導(dǎo)致頁面上展示的數(shù)組順序錯(cuò)亂
在實(shí)例化cell的時(shí)候, 把cell的賦值放在了實(shí)例化的方法里,, 出現(xiàn)了cell復(fù)用的問題,每次cell為空的時(shí)候,就會創(chuàng)建一個(gè), 重新賦值,就會出現(xiàn)問題
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
LoanPartTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"loanPartCell"];
if (cell == nil) {
cell = [[LoanPartTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"loanPartCell"];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.model = self.sectionOneNewArray[indexPath.row];
}
return cell;
}
把cell的賦值拿到外面去實(shí)現(xiàn), 或者直接采用tableview注冊cell的方法就可以避免這個(gè)問題
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
LoanPartTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"loanPartCell"];
if (cell == nil) {
cell = [[LoanPartTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"loanPartCell"];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
cell.model = self.sectionOneNewArray[indexPath.row];
return cell;
}
8. tableview頁面滑動時(shí)卡頓, 來回切換視圖,卡頓時(shí), 優(yōu)化方法
把圖片放在異步線程中加載, 采用緩存的形式, SDWebImage
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
if (!([model.iconUrlStr isKindOfClass:[NSNull class]])) {
NSString *urlStr = [QiNiuDownLoadUrl stringByAppendingString:model.iconUrlStr];
urlStr = [urlStr stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
[self.iconIMV sd_setImageWithURL:[NSURL URLWithString:urlStr] placeholderImage:[UIImage imageNamed:@"home_laba"]]; //小喇叭圖標(biāo)獲取
}
});