STImgePickerViewC.m 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. //
  2. // STImgePickerViewC.m
  3. // BuguLive
  4. //
  5. // Created by 岳克奎 on 17/4/17.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. #import "STImgePickerViewC.h"
  8. #import "UIImage+STCommon.h"
  9. #import <MobileCoreServices/MobileCoreServices.h>
  10. @interface STImgePickerViewC ()
  11. @end
  12. @implementation STImgePickerViewC
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. // Do any additional setup after loading the view.
  16. }
  17. #pragma mark ------------------------- System
  18. -(void)showSystemImgPickerC
  19. {
  20. UIImagePickerController *imgPickerCtrl = [[UIImagePickerController alloc] init];
  21. imgPickerCtrl.delegate = self;
  22. if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary] == YES)
  23. {
  24. imgPickerCtrl.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
  25. //弹出模态
  26. [self presentViewController:imgPickerCtrl
  27. animated:YES
  28. completion:^{
  29. }];
  30. }else{
  31. return;
  32. }
  33. }
  34. #pragma mark - 系统 -完成照片选择回调(子重写)
  35. - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
  36. {
  37. NSLog(@"info:%@",info);
  38. }
  39. #pragma - 系统imgPickerC -图片保存成功 回调
  40. - (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
  41. {
  42. NSLog(ASLocalizedString(@"图片不写本地吧"));
  43. }
  44. #pragma - 系统imgPickerC - 取消按钮
  45. - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
  46. {
  47. [self dismissViewControllerAnimated:YES
  48. completion:^{
  49. }];
  50. }
  51. #pragma *********************** Public 公有方法区域 *************************
  52. #pragma mark ----- 设置IPC类型
  53. // 启动IPC
  54. -(void)showSystemIPC:(BOOL)isSystemIPC andMaxSelectNum:(int)maxSelectNum
  55. {
  56. if (maxSelectNum == 0)
  57. {
  58. return;
  59. }
  60. // 系统
  61. if(isSystemIPC){
  62. UIImagePickerController *imgPickerCtrl = [[UIImagePickerController alloc] init];
  63. //设置代理
  64. imgPickerCtrl.delegate = self;
  65. if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary] == YES) {
  66. imgPickerCtrl.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
  67. imgPickerCtrl.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
  68. //弹出模态
  69. [self presentViewController:imgPickerCtrl animated:YES
  70. completion:^{
  71. }];
  72. }else{
  73. [[BGHUDHelper sharedInstance]tipMessage:ASLocalizedString(@"设备不支持视频")];
  74. return;
  75. }
  76. }
  77. //第三方
  78. else{
  79. [self tzImagePickerController];
  80. self.tzImagePickerController.maxImagesCount = maxSelectNum;
  81. //写真动态 要求2-20 张。。。不再改变方法这样处理吧
  82. if(maxSelectNum == 20){
  83. self.tzImagePickerController.minImagesCount = 2;
  84. }
  85. //弹出模态
  86. [self presentViewController:self.tzImagePickerController
  87. animated:YES
  88. completion:^{
  89. }];
  90. }
  91. }
  92. #pragma mark -----IPC数据下发(子重写)
  93. -(void)showSelectedMAray:(NSMutableArray *)selectedMArray
  94. {
  95. }
  96. #pragma mark ---------- 发布(子重写)
  97. //(为了统一,所有发布方法一致)
  98. -(void)showPublishDynamic
  99. {
  100. //Edit -1 价格
  101. }
  102. #pragma mark************************* Getter 方法区域 ****************************
  103. #pragma mark-
  104. -(TZImagePickerController *)tzImagePickerController
  105. {
  106. if(!_tzImagePickerController)
  107. {
  108. //调用时候再决定最大选择数目
  109. _tzImagePickerController = [[TZImagePickerController alloc]
  110. initWithMaxImagesCount:9
  111. delegate:self];
  112. // 隐藏不可以选中的图片,默认是NO,不推荐将其设置为YES
  113. _tzImagePickerController.hideWhenCanNotSelect = YES;
  114. // 隐藏不可以选中的图片,默认是NO,不推荐将其设置为YES
  115. _tzImagePickerController.hideWhenCanNotSelect = YES;
  116. _tzImagePickerController.navigationBar.tintColor = kAppGrayColor1;
  117. _tzImagePickerController.naviBgColor = kAppGrayColor1;
  118. _tzImagePickerController.naviTitleColor = kAppGrayColor1;
  119. _tzImagePickerController.barItemTextColor = kAppGrayColor1;
  120. }
  121. return _tzImagePickerController;
  122. }
  123. #pragma mark************************* Delegate 协议方法区域 *************************
  124. //第三方Photo选择-对应的代理方法
  125. #pragma mark---------------- <TZImagePickerControllerDelegate>
  126. // photos数组里的UIImage对象,默认是828像素宽,你可以通过设置photoWidth属性的值来改变它
  127. - (void)imagePickerController:(TZImagePickerController *)picker
  128. didFinishPickingPhotos:(NSArray<UIImage *> *)photos
  129. sourceAssets:(NSArray *)assets
  130. isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto{
  131. //数据的下发留给 子类
  132. NSLog(@"phos --------%lu",(unsigned long)photos.count);
  133. self.photoMArray = photos.mutableCopy;//图文不需要这个,图文比较特殊,需要加+ 这个图 还能修改数组
  134. [self showSelectedMAray:photos.mutableCopy];
  135. [_tzImagePickerController removeFromParentViewController];
  136. _tzImagePickerController = nil;
  137. }
  138. - (void)imagePickerController:(TZImagePickerController *)picker
  139. didFinishPickingPhotos:(NSArray<UIImage *> *)photos sourceAssets:(NSArray *)assets isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto infos:(NSArray<NSDictionary *> *)infos{
  140. }
  141. - (void)tz_imagePickerControllerDidCancel:(TZImagePickerController *)picker
  142. {
  143. [self dismissViewControllerAnimated:YES completion:^{
  144. }];
  145. }
  146. // If user picking a video, this callback will be called.
  147. // If system version > iOS8,asset is kind of PHAsset class, else is ALAsset class.
  148. // 如果用户选择了一个视频,下面的handle会被执行
  149. // 如果系统版本大于iOS8,asset是PHAsset类的对象,否则是ALAsset类的对象
  150. - (void)imagePickerController:(TZImagePickerController *)picker didFinishPickingVideo:(UIImage *)coverImage sourceAssets:(id)asset{
  151. }
  152. // If user picking a gif image, this callback will be called.
  153. // 如果用户选择了一个gif图片,下面的handle会被执行
  154. - (void)imagePickerController:(TZImagePickerController *)picker didFinishPickingGifImage:(UIImage *)animatedImage sourceAssets:(id)asset{
  155. }
  156. #pragma mark************************* Getter *********************
  157. #pragma mark------------ 构建上传服务类
  158. //-(BGOssManager *)ossManager
  159. //{
  160. // if (!_ossManager)
  161. // {
  162. // _ossManager = [[BGOssManager alloc]initWithDelegate:self];
  163. // }
  164. // return _ossManager;
  165. //}
  166. #pragma mark************************* 地图类 (子类调用)*********************
  167. -(void)showSTBMKViewC{
  168. STBMKCenter *stBMKCenter = [STBMKCenter shareManager];
  169. FWWeakify(self)
  170. [stBMKCenter showAdressLatitudeLongitudeDataComplete:^(BOOL finished) {
  171. NSLog(@"-------%ld----",stBMKCenter.poiListMArray.count);
  172. FWStrongify(self)
  173. if (stBMKCenter.poiListMArray.count == 0)
  174. {
  175. return ;
  176. }
  177. STBMKViewC *newViewC = (STBMKViewC *)[STBMKViewC showSTBaseViewCOnSuperViewC:self
  178. andFrameRect:CGRectMake(0, 0, kScreenW, kScreenH)
  179. andSTViewCTransitionType:STViewCTransitionTypeOfPush
  180. andComplete:^(BOOL finished,
  181. STBaseViewC *stBaseViewC) {
  182. }];
  183. //
  184. [newViewC setDelegate:self];
  185. // 开启IQ
  186. newViewC.isOpenIQKeyboardManager = YES;
  187. // 加载View层
  188. [newViewC stBMKView];
  189. newViewC.stBMKView.dataSoureMArray = stBMKCenter.poiListMArray.mutableCopy;
  190. [newViewC.stBMKView.tableView reloadData];
  191. //跳转
  192. //TabBarc隐藏
  193. self.hidesBottomBarWhenPushed=YES;
  194. self.navigationController.navigationBar.tintColor = kAppGrayColor1;
  195. [self.navigationController pushViewController:newViewC
  196. animated:YES];
  197. newViewC.title = ASLocalizedString(@"所在位置");
  198. newViewC.navigationController.navigationBar.hidden = NO;
  199. newViewC.navigationController.navigationBar.tintColor = kAppGrayColor1;
  200. //
  201. newViewC.navigationItem.rightBarButtonItem = newViewC.rightBarButtonItem;
  202. //改变颜色 必须跳转后
  203. [newViewC.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:19],NSForegroundColorAttributeName:kAppGrayColor1}];
  204. self.hidesBottomBarWhenPushed=YES;
  205. }];
  206. }
  207. #pragma mark----------- 地图数据更新 (留给子重写)
  208. -(void)showUpdateLoactionInfoOfIndexPath{
  209. //找到cell
  210. // NSIndexPath *indexPath=[NSIndexPath indexPathForRow:0 inSection:2];
  211. //[self.graphicDynamicView.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil]
  212. // withRowAnimation:UITableViewRowAnimationNone];
  213. }
  214. - (void)ceartVideoViewWithType:(int)type
  215. {
  216. if (type == 0)
  217. {
  218. UIImagePickerController *imgPickerCtrl = [[UIImagePickerController alloc] init];
  219. //设置代理
  220. imgPickerCtrl.delegate = self;
  221. if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary] == YES) {
  222. imgPickerCtrl.sourceType = UIImagePickerControllerSourceTypeCamera;
  223. imgPickerCtrl.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
  224. //弹出模态
  225. [self presentViewController:imgPickerCtrl animated:YES
  226. completion:^{
  227. }];
  228. }else{
  229. [[BGHUDHelper sharedInstance]tipMessage:ASLocalizedString(@"设备不支持视频")];
  230. return;
  231. }
  232. }else if(type == 1)
  233. {
  234. UIImagePickerController *imgPickerCtrl = [[UIImagePickerController alloc] init];
  235. //设置代理
  236. imgPickerCtrl.delegate = self;
  237. if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary] == YES) {
  238. imgPickerCtrl.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
  239. imgPickerCtrl.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
  240. //弹出模态
  241. [self presentViewController:imgPickerCtrl animated:YES
  242. completion:^{
  243. }];
  244. }else{
  245. [[BGHUDHelper sharedInstance]tipMessage:ASLocalizedString(@"设备不支持视频")];
  246. return;
  247. }
  248. }else
  249. {
  250. [[AppDelegate sharedAppDelegate]popViewController];
  251. }
  252. }
  253. - (void)showMyVideoView
  254. {
  255. UIActionSheet *headImgSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
  256. [headImgSheet addButtonWithTitle:ASLocalizedString(@"拍摄视频")];
  257. [headImgSheet addButtonWithTitle:ASLocalizedString(@"相册中获取视频")];
  258. [headImgSheet addButtonWithTitle:ASLocalizedString(@"取消")];
  259. headImgSheet.cancelButtonIndex = headImgSheet.numberOfButtons-1;
  260. headImgSheet.delegate = self;
  261. [headImgSheet showInView:[UIApplication sharedApplication].keyWindow];
  262. }
  263. #pragma mark UIActionSheet的代理
  264. - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger) buttonIndex
  265. {
  266. if (buttonIndex == 0)
  267. {
  268. UIImagePickerController *imgPickerCtrl = [[UIImagePickerController alloc] init];
  269. //设置代理
  270. imgPickerCtrl.delegate = self;
  271. if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary] == YES) {
  272. imgPickerCtrl.sourceType = UIImagePickerControllerSourceTypeCamera;
  273. imgPickerCtrl.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
  274. //弹出模态
  275. [self presentViewController:imgPickerCtrl animated:YES
  276. completion:^{
  277. }];
  278. }else{
  279. [[BGHUDHelper sharedInstance]tipMessage:ASLocalizedString(@"设备不支持视频")];
  280. return;
  281. }
  282. }else if (buttonIndex == 1)
  283. {
  284. UIImagePickerController *imgPickerCtrl = [[UIImagePickerController alloc] init];
  285. //设置代理
  286. imgPickerCtrl.delegate = self;
  287. if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary] == YES) {
  288. imgPickerCtrl.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
  289. imgPickerCtrl.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
  290. //弹出模态
  291. [self presentViewController:imgPickerCtrl animated:YES
  292. completion:^{
  293. }];
  294. }else{
  295. [[BGHUDHelper sharedInstance]tipMessage:ASLocalizedString(@"设备不支持视频")];
  296. return;
  297. }
  298. }else
  299. {
  300. [self dismissViewControllerAnimated:YES completion:nil];
  301. }
  302. }
  303. @end