DKUITableViewController.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. //
  2. // UITableViewController.h
  3. // chatandvideotest
  4. //
  5. // Created by Dongke on 15/11/18.
  6. // Copyright © 2015年 dongke. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. // Model
  10. #import "DKMessage.h"
  11. // Views
  12. #import "DKMessageTableView.h"
  13. #import "DKUITableViewCell.h"
  14. #import "DKMessageInputView.h"
  15. #import "DKVoiceRecordHUD.h"
  16. #import "DKVoiceRecordHelper.h"
  17. @protocol DKUITableViewControllerDelegate <NSObject>
  18. @optional
  19. - (void)didSendVoice:(NSString *)voicePath voiceDuration:(NSString*)voiceDuration fromSender:(NSString *)sender onDate:(NSDate *)date;
  20. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath targetMessage:(id<DKMessageModel>)message;
  21. - (void)didCameraAction:(BOOL)flg;
  22. - (void)didPhotoAction:(BOOL)flg ;
  23. - (void)didPostionAction:(BOOL)flg ;
  24. @end
  25. @protocol DKUITableViewControllerDataSource <NSObject>
  26. @required
  27. - (id <DKMessageModel>)messageForRowAtIndexPath:(NSIndexPath *)indexPath;
  28. @optional
  29. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath targetMessage:(id<DKMessageModel>)message;
  30. @end
  31. @interface DKUITableViewController : UIViewController<UITableViewDataSource, UITableViewDelegate, DKUITableViewControllerDelegate, DKUITableViewControllerDataSource, DKUITableViewCellDelegate>
  32. @property (nonatomic, weak) id <DKUITableViewControllerDelegate> delegate;
  33. @property (nonatomic, weak) id <DKUITableViewControllerDataSource> dataSource;
  34. @property (nonatomic, assign, readonly) DKInputViewType textViewInputViewType;
  35. @property (nonatomic, assign) UIActivityIndicatorViewStyle loadMoreActivityIndicatorViewStyle;
  36. /**
  37. * 数据源,显示多少消息
  38. */
  39. @property (nonatomic, strong) NSMutableArray *messages;
  40. /**
  41. * 消息的主体,默认为nil
  42. */
  43. @property (nonatomic, copy) NSString *messageSender;
  44. /**
  45. * 用于显示消息的TableView
  46. */
  47. @property (nonatomic, weak) DKMessageTableView *messageTableView;
  48. /**
  49. * 用于显示发送消息类型控制的工具条,在底部
  50. */
  51. @property (nonatomic, weak, readonly) DKMessageInputView *messageInputView;
  52. #pragma mark - Message View Controller Default stup
  53. /**
  54. * 是否允许手势关闭键盘,默认是允许
  55. */
  56. @property (nonatomic, assign) BOOL allowsPanToDismissKeyboard; // default is YES
  57. /**
  58. * 是否允许发送语音
  59. */
  60. @property (nonatomic, assign) BOOL allowsSendVoice; // default is YES
  61. /**
  62. * 输入框的样式,默认为扁平化
  63. */
  64. @property (nonatomic, assign) DKMessageInputViewStyle inputViewStyle;
  65. /**
  66. * 添加一条新的消息
  67. *
  68. * @param addedMessage 添加的目标消息对象
  69. */
  70. - (void)addMessage:(DKMessage *)addedMessage;
  71. #pragma mark - Messages view controller
  72. /**
  73. * 设置View、tableView的背景颜色
  74. *
  75. * @param color 背景颜色
  76. */
  77. - (void)setBackgroundColor:(UIColor *)color;
  78. /**
  79. * 设置消息列表的背景图片
  80. *
  81. * @param backgroundImage 目标背景图片
  82. */
  83. - (void)setBackgroundImage:(UIImage *)backgroundImage;
  84. /**
  85. * 是否滚动到底部
  86. *
  87. * @param animated YES Or NO
  88. */
  89. - (void)scrollToBottomAnimated:(BOOL)animated;
  90. /**
  91. * 滚动到哪一行
  92. *
  93. * @param indexPath 目标行数变量
  94. * @param position UITableViewScrollPosition 整形常亮
  95. * @param animated 是否滚动动画,YES or NO
  96. */
  97. - (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath
  98. atScrollPosition:(UITableViewScrollPosition)position
  99. animated:(BOOL)animated;
  100. #pragma mark - Other Menu View Frame Helper Mehtod
  101. /**
  102. * 根据显示或隐藏的需求对所有第三方Menu进行管理
  103. *
  104. * @param hide 需求条件
  105. */
  106. - (void)layoutOtherMenuViewHiden:(BOOL)hide;
  107. @end