iOS UI、Xcode、调试、代码等常见问题总汇(持续更新中)
以前比較懶,遇到問題解決了就完事了,有些問題再次遇到時(shí)忘記了當(dāng)初是怎么解決的,又要查各種資料來解決。好記憶不如爛筆頭,不管簡(jiǎn)單還是復(fù)雜都記一下吧,所以決定寫一篇常見問題總結(jié),方便以后查閱。現(xiàn)在有點(diǎn)忙,先寫兩個(gè)剛剛遇到的簡(jiǎn)單的吧,還有很多,以后遇到一個(gè)寫一個(gè)。
一、UI類常見問題
1.UITableView中自定義的HeaderView顏色無效不顯示
需要給HeaderView設(shè)置一個(gè)backgroundView,設(shè)置backgroundView的背景色即可。
AccountHeaderView *view = (AccountHeaderView *)[tableView dequeueReusableHeaderFooterViewWithIdentifier:@"AccountHeaderView"]; UIView *v = [[UIView alloc]init];v.backgroundColor = [UIColor colorWithRed:219/255.0f green:108/255.0f blue:35/255.0f alpha:1];view.backgroundView = v;2.UITableViewCell中加UIScrollView,UIScrollView屏蔽了UITableViewCell的點(diǎn)擊事件
cell.m文件中加入下面代碼(_svData就是cell上的UIScrollView)
- (void)awakeFromNib {// Initialization code [self.contentView addGestureRecognizer:_svData.panGestureRecognizer]; }3.Auto Layout布局,viewController中應(yīng)該緊靠導(dǎo)航條的tableview或者scrollView偏下一段距離的問題
選中controller,不要勾選Adjust Scroll View Insets即可
?二、oc代碼中常見問題
1.NSData轉(zhuǎn)NSString為空(nil)
例如Base64字符串解碼時(shí)會(huì)先解碼成NSData類型,NSData轉(zhuǎn)成NSString時(shí)有可能為nil。
下面例子有可能為nil:
NSString *str = [[NSString alloc]initWithData:myData encoding:NSUTF8StringEncoding];解決辦法:
NSString *str = [[NSString alloc]initWithData:myData encoding:CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000)];?
三、API中常見問題
1.iOS8以后地圖無法定位、沒走到delegate回調(diào)方法中
在Info.plist中加入兩個(gè)缺省沒有的字段
-
NSLocationAlwaysUsageDescription
-
NSLocationWhenInUseUsageDescription
- 都設(shè)置為YES
四、調(diào)試常見問題
- 1.iOS duplicate symbol for architecture arm64 解決辦法
- 2.iOS Undefined symbols for architecture arm64解決辦法3.iOS import framework頭文件時(shí)報(bào)錯(cuò)could not build module xxx
-
轉(zhuǎn)載于:https://www.cnblogs.com/zhanglinfeng/p/5145106.html
超強(qiáng)干貨來襲 云風(fēng)專訪:近40年碼齡,通宵達(dá)旦的技術(shù)人生總結(jié)
以上是生活随笔為你收集整理的iOS UI、Xcode、调试、代码等常见问题总汇(持续更新中)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C# 版本设计模式(Design Pat
- 下一篇: VxWorks6.6 pcPentium