liangtong


  • 首页

  • 标签

  • 分类

  • 归档

  • 关于

  • 搜索

GoogleWebRTC实时通讯

发表于 2017-11-21 | 分类于 即时通讯 | 阅读次数:

WebRT(Web browsers with Real-Time Communications)是一个由谷歌支持免费、开源的项目。本节主要讲述iOS端音视频实时通话,跨局域网需要搭建NAT穿墙服务器。

引入

移动端可以通过Pod命令,直接使用由Google编译好的framework。

1
pod 'GoogleWebRTC'

谷歌提供的WebRTC.framework支持处理器: x86_64 armv7 arm64,不包含i386

阅读全文 »

Xcode9中TableViewCell高度自适应

发表于 2017-11-01 | 分类于 iOS | 阅读次数:

​ 前几天升级了Xcode9后,在对一个项目进行调试时突然发现有个使用UITableView的自定义Cell展示异常了,然后控制台报了一大堆的约束警告。

1
2
3
4
"<NSLayoutConstraint:0x60c0000977f0 UIView:0x7fbb8c7841d0.bottom == UILabel:0x7fbb8c7870e0.bottom + 8>",
"<NSLayoutConstraint:0x60c0000979d0 UIView:0x7fbb8c7841d0.top == UITableViewCellContentView:0x7fbb8c781b70.top>",
"<NSLayoutConstraint:0x60c000097a70 UITableViewCellContentView:0x7fbb8c781b70.bottom == UIView:0x7fbb8c7841d0.bottom + 2>",
"<NSLayoutConstraint:0x60c000098bf0 UITableViewCellContentView:0x7fbb8c781b70.height == 44>"

从log上看,觉得应该是tableview的高度设置有问题。于是查看对应 Controller 相关代码。

1
2
3
4
//注册自定义TableViewCell
[self.tableView registerNib:[UINib nibWithNibName:@"GKProjectSearchHeaderFilterView" bundle:nil] forHeaderFooterViewReuseIdentifier:GKProjectSearchHeaderFilterViewIdentifier];
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tableView.estimatedRowHeight = 60.0f;

rowHeight

代码没有问题,无奈点开UITableView文件进行查看,发现还有个 rowHeight 属性,印象中之前如果使用 estimatedRowHeight 时不设置 rowHeight 也没有影响。考虑到log信息,决定添加上该属性设置

1
self.tableView.rowHeight = UITableViewAutomaticDimension;

界面表现正常!

如果不设置 rowHeight 属性时,实现 UITableViewDelegate 协议的方法也可以,但是 从性能方面考虑,不建议使用协议的方式 。

1
2
3
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return UITableViewAutomaticDimension;
}

结论

应该是Xcode9在处理UITableView时,对属性 rowHeight 的支持出现了问题。以下摘自UIKit中源码。

1
@property (nonatomic) CGFloat rowHeight; // default is UITableViewAutomaticDimension

注释中提到该属性的默认值就是UITableViewAutomaticDimension。

CocoaPods个人代码组件管理

发表于 2017-10-16 | 分类于 技术分享 | 阅读次数:

Cocoapods是非常好用的一个iOS依赖管理工具,使用它可以方便的管理和更新项目中所使用到的第三方库,本节介绍如何将自己的组件代码交由它去管理。

创建Git仓库

根据GitHub提示操作即可,建立自己的Git仓库。

创建podspec文件

终端直接执行以下命令,创建Pod项目工程文件,例如要创建一个叫做 LTChat 的Pod工程,命令执行成功后,会看到一个叫做 LTChat.podspec 的文件。

1
pod spec create "LTChat"

阅读全文 »
123…20
liangtong

liangtong

Keep hungry keep foolish!

59 日志
7 分类
17 标签
GitHub E-Mail 微博 知乎
友情链接
  • lidm1989
© 2016 — 2018 liangtong
由 Hexo 强力驱动
|
主题 — NexT.Pisces v5.1.4