PDFListViewController.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. //
  2. // PDFListViewController.m
  3. // RedAnt ERP Mobile
  4. //
  5. // Created by Ray on 11/23/15.
  6. // Copyright © 2015 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "PDFListViewController.h"
  9. #import "PDFListTableViewCell.h"
  10. #import "iSalesNetwork.h"
  11. #import "PDFViewController.h"
  12. #import "MainViewController.h"
  13. #import "DefaultAppearance.h"
  14. #import "DefaultTableHeaderView.h"
  15. #import "SortItemViewController.h"
  16. #import "UIColor+JK_HEX.h"
  17. @interface PDFListViewController ()
  18. @end
  19. @implementation PDFListViewController
  20. -(void) logout
  21. {
  22. self.offset = 0;
  23. self.limit = 25;
  24. [self.content_data removeAllObjects];
  25. }
  26. - (void)viewDidLoad {
  27. [super viewDidLoad];
  28. self.offset = 0;
  29. self.limit = 25;
  30. self.content_data = [[NSMutableArray alloc]init];
  31. UIRefreshControl *ref = [[UIRefreshControl alloc]init];
  32. ref.tag = 201 ;
  33. ref.attributedTitle = [[NSAttributedString alloc]initWithString:@"Pull to refresh"];
  34. ref.tintColor = [UIColor colorWithRed:0.10 green:0.68 blue:0.94 alpha:0.7];
  35. // ref.hidden = true;
  36. [ref addTarget:self action:@selector(manually_refresh) forControlEvents:UIControlEventValueChanged];
  37. [self.table addSubview:ref];
  38. self.label_net_err.layer.borderColor = [UIColor darkGrayColor].CGColor;
  39. self.label_net_err.layer.borderWidth = 2.0;
  40. self.label_net_err.layer.cornerRadius=15;
  41. self.label_net_err.layer.masksToBounds=true;
  42. CGPoint center = self.mum.center;
  43. self.mum.frame = CGRectMake(0, 0, 100, 100);
  44. self.mum.center = center;
  45. self.mum.backgroundColor = [UIColor colorWithHEX:0xA5A5A5 alpha:0.5];
  46. self.mum.layer.cornerRadius = 5.0f;
  47. self.mum.layer.masksToBounds = YES;
  48. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(refresh_btn_click:)];
  49. // tap.minimumPressDuration = 0.8; //定义按的时间
  50. [self.label_net_err addGestureRecognizer:tap];
  51. // Do any additional setup after loading the view.
  52. }
  53. - (void)didReceiveMemoryWarning {
  54. [super didReceiveMemoryWarning];
  55. // Dispose of any resources that can be recreated.
  56. }
  57. -(void) reload_container_getdata:(bool) update_data
  58. {
  59. [super reload_container_getdata:update_data];
  60. if(update_data)
  61. {
  62. self.offset = 0;
  63. [self.content_data removeAllObjects];
  64. self.norefresh=true;
  65. [self loadpage];
  66. }
  67. else
  68. [self.table reloadData];
  69. }
  70. - (void)viewWillAppear:(BOOL)animated
  71. {
  72. [super viewWillAppear:animated];
  73. // if(!self.norefresh)//避免 多次刷新
  74. // {
  75. // self.norefresh = true;
  76. // self.offset = 0;
  77. // [self.content_data removeAllObjects];
  78. // [self loadpage];
  79. //
  80. // }
  81. [[self navigationController] setNavigationBarHidden:YES animated:NO];
  82. }
  83. -(void)manually_refresh
  84. {
  85. UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:201];
  86. if(self.isrefreshing)
  87. {
  88. [reF endRefreshing];
  89. return;
  90. }
  91. reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"Refreshing"];
  92. [self performSelector:@selector(ReloadData) withObject:nil afterDelay:1];
  93. }
  94. -(void)ReloadData
  95. {
  96. [self.content_data removeAllObjects];
  97. [self.table reloadData];
  98. // self.table_order.hidden = true;
  99. UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:201];
  100. [reF endRefreshing];
  101. reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"Pull to refresh"];
  102. self.keywords=self.searchbar.text;
  103. self.offset = 0;
  104. // [self.content_data removeAllObjects];
  105. // [self.table_order reloadData];
  106. [self loadpage];
  107. // [self loadpage];
  108. }
  109. -(void) loadpage
  110. {
  111. dispatch_async(dispatch_get_main_queue(), ^{
  112. if(self.isrefreshing)
  113. return;
  114. self.label_net_err.hidden=true;
  115. self.isrefreshing=true;
  116. self.table.hidden =true;
  117. self.mum.center = self.view.center;
  118. self.mum.hidden = false;
  119. [self.mum startAnimating];
  120. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  121. NSMutableDictionary* content=nil;
  122. content=[[iSalesNetwork request_PDFList:self.offset limit : self.limit keywords:self.keywords] mutableCopy];
  123. dispatch_async(dispatch_get_main_queue(), ^{
  124. [self.mum stopAnimating];
  125. int result=[[content valueForKey:@"result"] intValue];
  126. if(result==2||result==0)
  127. {
  128. self.table.hidden =false;
  129. int count = [[content valueForKey:@"count" ] intValue] ;
  130. // self.time_zone = [content valueForKey:@"time_zone" ];
  131. self.offset += count;
  132. for(int i=0;i<count;i++)
  133. {
  134. NSDictionary* objmsg = [content objectForKey:[NSString stringWithFormat:@"item_%d",i]];
  135. [self.content_data addObject:[NSMutableDictionary dictionaryWithDictionary:objmsg]];
  136. DebugLog(@"content_data: %@",self.content_data);
  137. }
  138. if(count<self.limit)
  139. {
  140. // int i =self.btnrefresh.state;
  141. self.load_more_hint=@"All loaded";
  142. // self.btnrefresh.titleLabel.text =NSLocalizedString(@"no_more", nil);
  143. // [self.btnrefresh setTitle:@"No more" forState:UIControlStateNormal];
  144. }
  145. else
  146. {
  147. self.load_more_hint=@"Load more...";
  148. // self.btnrefresh.enabled = true;
  149. // self.btnrefresh.titleLabel.text =NSLocalizedString(@"load_more",nil);
  150. // [self.btnrefresh setTitle:@"Load more" forState:UIControlStateNormal];
  151. }
  152. [self.table reloadData ];
  153. }
  154. else if(result==RESULT_NET_ERROR)
  155. {
  156. self.label_net_err.hidden=false;
  157. self.table.hidden=true;
  158. }
  159. else
  160. {
  161. [RAUtils message_alert:[content valueForKey:@"err_msg"] title:@"Loading Portfilio List" controller:self] ;
  162. }
  163. // NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
  164. // bool autologin =[defaults boolForKey:@"autologin"];
  165. // if(!autologin)
  166. // {
  167. // TabBarController * viewController =[self.storyboard instantiateViewControllerWithIdentifier:@"LoginTabBar"];
  168. // [self presentViewController:viewController animated:YES completion:^{
  169. //
  170. // }];
  171. // }
  172. self.isrefreshing=false;
  173. });
  174. });
  175. });
  176. }
  177. - (void)loadmore
  178. {
  179. // self.btnrefresh.enabled = NO;
  180. // self.btnrefresh.titleLabel.text =NSLocalizedString(@"loading",nil);
  181. // [self.btnrefresh setTitle:@"Loading..." forState:UIControlStateNormal];
  182. [self loadpage];
  183. }
  184. /*
  185. #pragma mark - Navigation
  186. // In a storyboard-based application, you will often want to do a little preparation before navigation
  187. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  188. // Get the new view controller using [segue destinationViewController].
  189. // Pass the selected object to the new view controller.
  190. }
  191. */
  192. #pragma mark - Table view data source
  193. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
  194. {
  195. return 66;
  196. }
  197. //- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  198. //{
  199. // return 0;
  200. //}
  201. //- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  202. //{
  203. // return 0;
  204. //}
  205. //- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
  206. //{
  207. // UIView* myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
  208. // return myView;
  209. //
  210. //}
  211. - (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  212. {
  213. NSString* value =[DefaultAppearance get_noneappearance_value:@"DefaultTableHeaderView" valuename:@"title_text_color"];
  214. if(value==nil)
  215. value=@"";
  216. unsigned long color = strtoul([value UTF8String],0,16);
  217. DefaultTableHeaderView* myView = [[DefaultTableHeaderView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
  218. // myView.backgroundColor = UIColorFromRGB(color);
  219. myView.layer.shadowColor = [UIColor blackColor].CGColor;
  220. myView.layer.shadowOffset = CGSizeMake(0, 0);
  221. myView.layer.shadowOpacity = 0.5;
  222. myView.layer.shadowRadius = 2.0;
  223. UILabel *namelabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 11, 75, 22)];
  224. namelabel.textColor=UIColorFromRGB(color);
  225. namelabel.backgroundColor = [UIColor clearColor];
  226. namelabel.text=NSLocalizedString(@"Name", nil);
  227. [namelabel sizeToFit];
  228. [myView addSubview:namelabel];
  229. // UILabel *solabel = [[UILabel alloc] initWithFrame:CGRectMake(173, 5.5, 130, 22)];
  230. // solabel.textColor=[UIColor whiteColor];
  231. // solabel.backgroundColor = [UIColor clearColor];
  232. // solabel.text=NSLocalizedString(@"Name", nil);
  233. // [solabel sizeToFit];
  234. // [myView addSubview:solabel];
  235. UILabel *notelabel = [[UILabel alloc] initWithFrame:CGRectMake(250, 11, 75, 22)];
  236. notelabel.textColor=UIColorFromRGB(color);
  237. notelabel.backgroundColor = [UIColor clearColor];
  238. notelabel.text=NSLocalizedString(@"Notes", nil);
  239. [notelabel sizeToFit];
  240. [myView addSubview:notelabel];
  241. UILabel *timelabel = [[UILabel alloc] initWithFrame:CGRectMake(self.table.frame.size.width-163,11, 148, 22)];
  242. timelabel.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin;
  243. timelabel.textColor=UIColorFromRGB(color);
  244. timelabel.backgroundColor = [UIColor clearColor];
  245. timelabel.text=@"Create time";
  246. [timelabel sizeToFit];
  247. [myView addSubview:timelabel];
  248. myView.autoresizesSubviews=true;
  249. // [myView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin];
  250. // modellabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  251. // pricelabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  252. // timelabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  253. myView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
  254. //
  255. return myView;
  256. }
  257. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  258. {
  259. return 44;
  260. }
  261. //
  262. //- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
  263. // if(section==0)
  264. // return nil;
  265. // else
  266. // return @"detail section";
  267. //}
  268. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  269. {
  270. return 1;
  271. }
  272. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  273. {
  274. // NSDictionary * item_json = [self.content_data objectForKey:@"items"];
  275. if( self.content_data.count==0)
  276. return 0;
  277. return self.content_data.count+1;
  278. }
  279. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  280. {
  281. // if(tableView==self.itemListTable)
  282. // {
  283. // if(indexPath.row>self.content_data.count)
  284. // {
  285. // int debug=true;
  286. // }
  287. // NSLog(@"row %ld",(long)indexPath.row);
  288. if(indexPath.row==self.content_data.count)
  289. {
  290. UITableViewCell *moreCell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"mores"];
  291. UILabel *moreDataLabel=[[UILabel alloc] init];
  292. moreDataLabel.tag=200;
  293. moreDataLabel.text=self.load_more_hint;
  294. [moreDataLabel setFont:[UIFont systemFontOfSize:14.0f]];
  295. [moreDataLabel setTextAlignment:NSTextAlignmentCenter];
  296. moreDataLabel.frame=CGRectMake(0, 10, self.table.bounds.size.width, 20);
  297. [moreDataLabel setBackgroundColor:[UIColor clearColor]];
  298. // [moreDataLabel addTarget:self action:@selector(changeCell) forControlEvents:UIControlEventValueChanged];
  299. [moreCell.contentView addSubview:moreDataLabel];
  300. if([self.load_more_hint isEqualToString:@"Load more..."])
  301. [self performSelector:@selector(loadmore) withObject:nil afterDelay:1];
  302. // NSLog(@"更多...");
  303. moreCell.backgroundColor = [UIColor whiteColor];
  304. return moreCell;
  305. }
  306. else
  307. {
  308. NSString *CellIdentifier = @"PDFListTableViewCell";
  309. PDFListTableViewCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  310. // int _id= [[self.content_data[indexPath.row] valueForKey:@"_id"] intValue];
  311. NSString* name= [self.content_data[indexPath.row] valueForKey:@"tear_name"];
  312. NSString* note= [self.content_data[indexPath.row] valueForKey:@"tear_note"];
  313. NSString* create_time= [self.content_data[indexPath.row] valueForKey:@"create_time"];
  314. // NSString* type = [self.content_data[indexPath.row] valueForKey:@"type"] ;
  315. // NSString* file_name = [self.content_data[indexPath.row] valueForKey:@"file_name"];
  316. cell.labelName.text = name;
  317. cell.labelTime.text = create_time;
  318. cell.labelNote.text = note;
  319. // cell.labelType.text = type;
  320. // cell.labelprice.text=price;
  321. // cell.label_date.text=purchase_time;
  322. // cell.label_contact.text=customer_name;
  323. // cell.label_model.text = model_count;
  324. //
  325. // cell.label_status.text=status;
  326. cell.backgroundColor = [UIColor whiteColor];
  327. return cell;
  328. }
  329. // NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
  330. // NSDictionary * combine_json =[item_json objectForKey:@"combine"];
  331. // cell.bundle_item=combine_json;
  332. // NSString* img_url = [item_json valueForKey:@"img_url"];
  333. // NSString* description = [item_json valueForKey:@"description"];
  334. // // NSString* identifier = [item_json valueForKey:@"identifier"];
  335. // // NSString* attribute = [item_json valueForKey:@"attribute"];
  336. // NSString* currency = [item_json valueForKey:@"currency"];
  337. // int count =[[item_json valueForKey:@"count"] intValue];
  338. // double price =[[item_json valueForKey:@"price"] doubleValue];
  339. // // cell.labelAttribute.text = attribute;
  340. // cell.labelCurrency.text = currency;
  341. // cell.labelDescription.text = description;
  342. // // cell.labelIdentifier.text = identifier;
  343. // cell.labelPrice.text = [NSString stringWithFormat:@"%.2f",price];
  344. //
  345. //
  346. //
  347. // [cell set_Count:count];
  348. // NSString* file_name=[img_url lastPathComponent];
  349. // NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
  350. // if(img_data!=nil)
  351. // {
  352. //
  353. // UIImage * img =[UIImage imageWithData:img_data];
  354. // [cell.btnImage setBackgroundImage:img forState:UIControlStateNormal];
  355. // }
  356. // else
  357. // {
  358. //
  359. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  360. //
  361. // NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
  362. //
  363. // dispatch_async(dispatch_get_main_queue(), ^{
  364. //
  365. //
  366. //
  367. // if(downloadimg_data!=nil)
  368. // {
  369. // [iSalesDB cache_img:downloadimg_data :file_name ];
  370. //
  371. // UIImage * img =[UIImage imageWithData:downloadimg_data];
  372. // [cell.btnImage setBackgroundImage:img forState:UIControlStateNormal];
  373. // }
  374. //
  375. // });
  376. // });
  377. //
  378. //
  379. // }
  380. // }
  381. // else
  382. // {
  383. // NSString *CellIdentifier = @"OrderInfoListItem";
  384. // UITableViewCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  385. // return cell;
  386. // }
  387. }
  388. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  389. {
  390. if(self.content_data.count== indexPath.row)
  391. return;
  392. NSString* name=[self.content_data[indexPath.row] valueForKey:@"tear_name"];
  393. NSString* url= [self.content_data[indexPath.row] valueForKey:@"pdf_path"];
  394. NSString* isLocalFile= [self.content_data[indexPath.row] valueForKey:@"isLocalFile"];
  395. PDFViewController *ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PDFViewController"];
  396. ViewController.url = url;
  397. ViewController.canSave = false;
  398. ViewController.isLocalfile=isLocalFile;
  399. NSString* subject;
  400. // if (company.length==0) {
  401. NSString* cur_time =[RAUtils current_date];
  402. subject =name;//[NSString stringWithFormat:@"NPD Product List %@",cur_time];
  403. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  404. NSString* customer_email= [appDelegate.customerInfo valueForKey:@"customer_email"];
  405. NSMutableArray* send_to = [[NSMutableArray alloc]init];
  406. if(customer_email.length>0)
  407. {
  408. send_to=[[customer_email componentsSeparatedByString:NSLocalizedString(@";", nil)] mutableCopy];
  409. // customer_email compo
  410. // [send_to addObject:customer_email];
  411. }
  412. ViewController.mail_to = send_to;
  413. // }
  414. // else
  415. // {
  416. // subject = [NSString stringWithFormat:@"Tear sheet for %@",company ];
  417. // }
  418. ViewController.attachment_name = [NSString stringWithFormat:@"NPD_Product_List %@.pdf",cur_time];
  419. ViewController.mail_subject = subject;
  420. ViewController.hidenavi = false;
  421. [self.navigationController pushViewController:ViewController animated:YES];
  422. //[self.navigationController setNavigationBarHidden:NO animated:NO];
  423. }
  424. #pragma mark - searchBar delegate;
  425. - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
  426. {
  427. self.keywords=searchBar.text;
  428. self.offset = 0;
  429. [self.content_data removeAllObjects];
  430. [self loadpage];
  431. }
  432. - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
  433. {
  434. if([searchText isEqualToString:@""] && !self.reset)
  435. {
  436. NSLog(@"clear");
  437. self.reset=true;
  438. self.keywords=nil;
  439. self.offset = 0;
  440. [self.content_data removeAllObjects];
  441. [self loadpage];
  442. }
  443. else
  444. self.reset = false;
  445. }
  446. #pragma mark 在滑动手势删除某一行的时候,显示出更多的按钮
  447. - (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
  448. {
  449. NSString* listid= [self.content_data[indexPath.row] valueForKey:@"tearsheetsId"];
  450. UITableViewRowAction *deleteRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"Delete" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
  451. NSLog(@"delete click");
  452. // UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Delete confirm", nil) message:NSLocalizedString(@"Are you sure to remove portfolio?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
  453. // // alert.tag = ALERT_DEL;
  454. // // alert.
  455. // [alert show];
  456. //
  457. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Are you sure to remove this portfolio?" message:nil preferredStyle:UIAlertControllerStyleAlert];
  458. //block代码块取代了delegate
  459. UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  460. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Remove Portfilio"];
  461. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  462. NSDictionary* cart_json = [iSalesNetwork delete_portfoliolist:listid];
  463. dispatch_async(dispatch_get_main_queue(), ^{
  464. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  465. if([[cart_json valueForKey:@"result"] intValue]==2)
  466. {
  467. [self ReloadData];
  468. }
  469. else
  470. {
  471. [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Portfolio" controller:self] ;
  472. }
  473. });
  474. });
  475. }];
  476. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  477. NSLog(@"No");
  478. }];
  479. [alertControl addAction:actionOne];
  480. [alertControl addAction:alertthree];
  481. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  482. [self presentViewController:alertControl animated:YES completion:nil];
  483. }];
  484. deleteRowAction.backgroundColor = UIColorFromRGB(0x336699);
  485. NSString* create_user= [self.content_data[indexPath.row] valueForKey:@"create_user"];
  486. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  487. if([create_user isEqualToString:appDelegate.user])
  488. {
  489. return @[deleteRowAction];
  490. }
  491. return nil;
  492. }
  493. - (void)tableView:(UITableView *)tableView
  494. commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
  495. }
  496. @end