1.Terminating app due to uncaught exception 'NSUnknownKeyException', reason
网上搜了一大堆,都是说XIB的关联问题,我把xib文件删除了连接,重新连了一下,还是报错。后来发现是我的代码问题。
NSMutableDictionary *dict = (NSMutableDictionary *)array.lastObject;
[dict setValue:textString forKey:@"limit"];
array.lastObject不是可变字典,这里我把它强转了,导致
[dict setValue:textString forKey:@"limit"];报错。
用 NSDictionary 就可以了。
2. 重新安装xcode cocoapods出现
Unable to download data from https://gems.ruby-china.org/ - bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)```, 即执行``` sudo gem install cocoapods
出现的错
执行 sudo -i
, 进入到 root 去执行 该命令
sudo -i
在去执行
sudo gem install cocoapods
结果为
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, 重新打开一个窗口,执行 pod --version
,查看版本,但是现在又报错了
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
结果为
Cleaning up installed gems...
Clean Up Complete
查看gem版本
gem update
结果为
2.6.14
接着执行
gem update
又报错了
Updating installed gems
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)
解决办法:
先后执行下面2行代码:
sudo gem sources -r https://rubygems.org
结果为:
Password:
source https://rubygems.org not present in cache
sudo gem sources -a http://rubygems.org
结果为:
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
就可以正常安装了
执行
sudo gem install cocoapods
结果为:
………………(代表还有很多命令)
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,执行命令 sudo gem update --system .出现了错误: 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,执行了下面命令更新pod之后,版本变为1.7.0.beta.3
sudo gem install -n /usr/local/bin cocoapods --pre
再去执行一些命令就好了
4. ld: framework not found Pods__________ clang: error: linker command failed with exit code 1 (use -v to see invocation)
出现这个问题,把Build Settings
---->的 Other Linker Flags
里面的所有库都删除了,就只剩下了第二个图里面的
然后把
Build Phases
的Linker Binary With Libraries
删除不存在(显示为颜色灰白)的库在command +shift +k, 清空一下,重新运行,即可了
5. ld: library not found for -lstdc++.6.0.9 , clang: error: linker command failed with exit code 1 (use -v to see invocation)
多数情况下是文件路径配置问题
在Building Phases
下面的 Link Binary With Libraries
把这个库show In Finder, 发现并不是在工程里路径下,重新把它拖到了工程目录里面,就好了。
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复用问题导致页面上展示的数组顺序错乱
在实例化cell的时候, 把cell的赋值放在了实例化的方法里,, 出现了cell复用的问题,每次cell为空的时候,就会创建一个, 重新赋值,就会出现问题
- (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的赋值拿到外面去实现, 或者直接采用tableview注册cell的方法就可以避免这个问题
- (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页面滑动时卡顿, 来回切换视图,卡顿时, 优化方法
把图片放在异步线程中加载, 采用缓存的形式, 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"]]; //小喇叭图标获取
}
});