这应该是这个系列最后一篇了。我写了很多都不是很好,不过如果不写,那就永远写不好。欢迎大家交流纠错。 UIMenuController,它不像Alert那么不友好,也不像ActionSheet,一定要点击一下;你可以无视它的出现,也可以通过它调用一些设定好的方法。它就长这样 ...
这应该是这个系列最后一篇了。我写了很多都不是很好,不过如果不写,那就永远写不好。欢迎大家交流纠错。
UIMenuController,它不像Alert那么不友好,也不像ActionSheet,一定要点击一下;你可以无视它的出现,也可以通过它调用一些设定好的方法。它就长这样:
这个控件是不是很熟悉,微信里面你长按就回出现的一个view。做IM的话,标杆就是wechat了,所以你们的产品怎么会放过它(你)呢。
先设计一个我们常用的场景:你在聊天界面,长按textView,然后弹出这个菜单,接着你点击了某一个Item。
聊天页面:tableView + inputBar(就是有输入框的一个view啦)。
这里面你会用到,tableView的的代理,要实现几个delegate。
1 #pragma mark - UITableViewDataSource & UITableViewDelegate 2 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 3 // 有多少条数据 4 return [dataArray count]; 5 } 6 7 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 8 static NSString * CellIdentifier = @"MessageCell"; 9 MessageCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];10 if (cell == nil) {11 cell = [MessageCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];12 cell.selectionStyle = UITableViewCellSelectionStyleDefault;13 }14 MessageModel * model = [dataArray objectAtIndex:indexPath.row];15 [cell setMyContent:model];16 return cell;17 }18 19 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {20 // 这里就用之前写到的的高度计算21 return #cellHeightFromModelData#;22 }
原标题:iOS IM开发建议(四)UIMenuController 怎么使用
关键词:IOS
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。