| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416 |
- //
- // DetailPageViewController.m
- // Apex Mobile
- //
- // Created by Ray on 14-3-8.
- // Copyright (c) 2014年 United Software Applications, Inc. All rights reserved.
- //
- #import "DetailPageViewController.h"
- //#import "AMShipMap.h"
- #define DEF_CELL_HEIGHT 44
- #define DEF_TABLE_HEIGHT 44
- #define LINE_WIDTH 0
- #define CELL_MARGIN 15
- #define LIST_VMARGIN 15
- #define LABEL_MARGIN 0
- #define NEW_MAPCELL_MARGIN 8
- #import "TabBarController.h"
- //#import "DetailCellTracking.h"
- #import <QuickLook/QuickLook.h>
- #import "DetailCellKVNew.h"
- #import "DetailCellContainer.h"
- #import "DetailCellContainerCA.h"
- #import "MyQLPreviewController.h"
- #import "LPShareActivity.h"
- #import "RADataProvider.h"
- //#import "AMCommEditCell.h"
- //#import "AMCommHeadCell.h"
- //#import "AMCommContentCell.h"
- //#import <Contacts/Contacts.h>
- //#import <ContactsUI/ContactsUI.h>
- //#define COMM_ID_HEAD @"COMM_ID_HEAD"
- //#define COMM_ID_CONTENT @"COMM_ID_CONTENT"
- //#define COMM_ID_EDIT @"COMM_ID_EDIT"
- @interface DetailHUD : UIView
- @property (nonatomic,strong) UILabel *msgLb;
- @end
- @implementation DetailHUD
- + (void)show:(NSString *)msg inView:(UIView *)view {
-
- if (!msg) {
- return;
- }
-
- DetailHUD *hud = [[DetailHUD alloc] initWithFrame:CGRectZero];
- hud.backgroundColor = [UIColor colorWithRed:0.2 green:0.2 blue:0.2 alpha:0.9];
- hud.msgLb.text = msg;
- [hud layoutSize];
- for (UIView *sub in view.subviews) {
- if ([sub isKindOfClass:self]) {
- sub.hidden = YES;
- }
- }
- [view addSubview:hud];
-
- [hud performSelector:@selector(hide) withObject:nil afterDelay:3.0f];
- }
- - (UILabel *)msgLb {
- if (!_msgLb) {
- _msgLb = [[UILabel alloc] initWithFrame:CGRectZero];
- _msgLb.textColor = [UIColor whiteColor];
- _msgLb.font = [UIFont systemFontOfSize:14.0f];
-
- [self addSubview:_msgLb];
- }
- return _msgLb;
- }
- - (void)layoutSize {
- [self.msgLb sizeToFit];
- CGSize size = self.msgLb.bounds.size;
-
- CGFloat height = size.height + 20;
- CGFloat width = size.width + 20;
- if (height < 30) {
- height = 30;
- }
- if (width < 30) {
- width = 30;
- }
-
- self.msgLb.center = CGPointMake(width * 0.5, height * 0.5);
- self.bounds = CGRectMake(0, 0, width, height);
-
- self.layer.cornerRadius = 5.0f;
- self.layer.masksToBounds = YES;
-
- }
- - (void)willMoveToSuperview:(UIView *)newSuperview {
- [super willMoveToSuperview:newSuperview];
-
- if (newSuperview) {
- self.center = CGPointMake(newSuperview.bounds.size.width * 0.5, newSuperview.bounds.size.height * 0.5);
- }
- }
- - (void)layoutSubviews {
- [super layoutSubviews];
-
- if (self.superview) {
- self.center = CGPointMake(self.superview.bounds.size.width * 0.5, self.superview.bounds.size.height * 0.5);
- }
- }
- - (void)hide {
- [self removeFromSuperview];
- }
- @end
- @interface DetailPageViewController () <QLPreviewControllerDataSource,QLPreviewControllerDelegate,DetailKVCellTapDelegate>
- @property (nonatomic,strong) MyQLPreviewController *quickLook;
- @property (nonatomic,copy) NSString *documentPath;
- @property (nonatomic,copy) NSString *email;
- @property (nonatomic,copy) NSString *email_subject;
- @property (nonatomic,copy) NSString *email_content;
- //@property (nonatomic,strong) IBOutlet AMShipMap *shipMap;
- @property (nonatomic,weak) UITableViewCell *editingCell;
- @property (nonatomic,strong) NSIndexPath *editingIndexPath;
- @property (nonatomic,strong) NSIndexPath *contactSelectIndexPath;
- @property (nonatomic,weak) UITapGestureRecognizer *tap;
- @property (nonatomic,assign) BOOL showKeyboard;
- @property (nonatomic,strong) NSIndexPath *containerSelectedIndexPath;
- @end
- @implementation DetailPageViewController
- - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
- {
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
- // Custom initialization
- }
- return self;
- }
- -(void)changeCell
- {
- UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
- reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"refreshing"];
- [self performSelector:@selector(ReloadData) withObject:nil afterDelay:1];
- DebugLog(@"refresh!!!!!!!!");
-
- }
- -(void)ReloadData
- {
-
- // Count ++ ;
- // [mytabelview reloadData];
- [self loadpage];
- UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
-
- [reF endRefreshing];
-
- }
- - (void)viewDidLoad
- {
- [super viewDidLoad];
-
- // self.webviewoprationQueue = [[NSOperationQueue alloc] init];
- // self.webviewoprationQueue.maxConcurrentOperationCount = 1;
-
- UIRefreshControl *ref = [[UIRefreshControl alloc]init];
- ref.tag = 200 ;
- ref.attributedTitle = [[NSAttributedString alloc]initWithString:@"drag to refresh"];
- ref.tintColor = [UIColor colorWithRed:0.10 green:0.68 blue:0.94 alpha:0.7];
- // ref.hidden = true;
- [ref addTarget:self action:@selector(changeCell) forControlEvents:UIControlEventValueChanged];
-
- [self.table addSubview:ref];
- if(self.tabBarController.tabBar.hidden==true)
- {
- CGRect frame = self.table.frame;
- frame.size.height +=40;
- self.table.frame=frame;
- }
- // self.view.backgroundColor= [UIColor whiteColor];
- [self loadpage];
- // Do any additional setup after loading the view.
-
- UIBarButtonItem *previewMenuBtn = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"ic_more_dot"] style:UIBarButtonItemStylePlain target:self action:@selector(quickLookMenuClick:)];
- self.quickLook.navigationItem.rightBarButtonItem = previewMenuBtn;
-
- // [self configureMap];
- [self configureTableView];
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- NSString *action_type = [self.params objectForKey:@"action_type"];
- // if ([action_type isEqualToString:@"Detail"]) { // 避免Tap与Tacking中Cell点击冲突
- // [self startListenKeyboard];
- // }
- //
- // if (self.shipMap) {
- // [self.shipMap shipMapWillAppear];
- // }
- }
- - (void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
- // [self stopListenKeyboard];
-
- // if (self.shipMap) {
- // [self.shipMap shipMapWillDisappear];
- // }
- }
- - (void)configureTableView {
-
- // [self.table registerNib:[UINib nibWithNibName:@"AMCommHeadCell" bundle:nil] forCellReuseIdentifier:COMM_ID_HEAD];
- // [self.table registerNib:[UINib nibWithNibName:@"AMCommContentCell" bundle:nil] forCellReuseIdentifier:COMM_ID_CONTENT];
- // [self.table registerNib:[UINib nibWithNibName:@"AMCommEditCell" bundle:nil] forCellReuseIdentifier:COMM_ID_EDIT];
- //
- }
- //- (void)configureMap {
- //
- // if (!self.showMap) {
- //
- // NSArray *constraints = [[self.view constraints] mutableCopy];
- // // 删除Table与Map相关约束
- // for (NSLayoutConstraint *constaint in constraints) {
- // if ([constaint.identifier isEqualToString:@"top_constraint"]) {
- // [self.view removeConstraint:constaint];
- // } else if ([constaint.identifier isEqualToString:@"ratio_constraint"]) {
- // [self.view removeConstraint:constaint];
- // }
- // }
- //
- //// // 移除地图
- //// [self.shipMap removeFromSuperview];
- //// self.shipMap = nil;
- //
- // // 设置新约束
- // NSLayoutConstraint *top = [NSLayoutConstraint constraintWithItem:self.table
- // attribute:NSLayoutAttributeTop
- // relatedBy:NSLayoutRelationEqual
- // toItem:self.topLayoutGuide
- // attribute:NSLayoutAttributeBottom
- // multiplier:1.0
- // constant:0];
- // [self.view addConstraint:top];
- //
- //
- //
- // [self.view layoutIfNeeded];
- // } else {
- // self.shipMap.showCurrent = YES;
- // self.shipMap.showPoe = YES;
- // self.shipMap.showPol = YES;
- // self.shipMap.showPod = YES;
- // self.shipMap.showPor = YES;
- // self.shipMap.showOrigin = YES;
- // self.shipMap.showDestination = YES;
- //
- // self.shipMap.delegate = self;
- // }
- //
- //}
- - (void)saveDocumentClick:(id)sender {
-
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- NSString *path = [paths objectAtIndex:0];
- NSString *filePath = [path stringByAppendingPathComponent:[self.documentPath lastPathComponent]];
-
- NSError *err;
-
- if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
- [[NSFileManager defaultManager] removeItemAtPath:filePath error:nil];
- }
- [[NSFileManager defaultManager] moveItemAtPath:self.documentPath toPath:filePath error:&err];
-
- UIAlertController *alertVC;
- UIAlertAction *action = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- if (err) {
- alertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:[NSString stringWithFormat:@"save document failed:\n%@",err.localizedDescription] preferredStyle:UIAlertControllerStyleAlert];
- } else {
- alertVC = [UIAlertController alertControllerWithTitle:nil message:@"Document Saved" preferredStyle:UIAlertControllerStyleAlert];
- }
- [alertVC addAction:action];
-
- [self presentViewController:alertVC animated:YES completion:nil];
-
- }
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- -(void) loadpage
- {
-
- // [self.params setValue:[NSString stringWithFormat:@"%d",self.offset] forKey:@"offset"];
- // self.prepageButton.enabled=false;
- // self.nextpageButton.enabled=false;
- self.mum.center = self.view.center;
- __weak typeof(self) weakSelf = self;
- NSTimeInterval animationDuration = 0.30f;
- [UIView beginAnimations:@"ResizeView" context:nil];
- [UIView setAnimationDuration:animationDuration];
-
- self.mum.hidden = false;
- self.table.hidden = true;
-
- [UIView commitAnimations];
-
- // if (self.showMap) {
- // [self.params setObject:@(YES) forKey:@"request_location"];
- // }
- // if ([[self.params objectForKey:@"action_type"] isEqualToString:@"Detail"]) {
- // [self.params setObject:@(YES) forKey:@"request_communication"];
- // }
- //
-
- [RADataProvider TabDetail:self.params completionHandler:^(NSMutableDictionary *result) {
- // ;
-
- self.content=[RADataProvider json2DetailContent:result];
-
- NSTimeInterval animationDuration = 0.30f;
- [UIView beginAnimations:@"ResizeView" context:nil];
- [UIView setAnimationDuration:animationDuration];
-
-
- self.mum.hidden = true;
- if(self.content.result_code!=RESULT_TRUE)
- {
-
- self.table.hidden =false;
- [self.table reloadData];
- UIAlertController *alertVC = [UIAlertController alertControllerWithTitle: @"Warning"
- message: self.content.err_msg
- preferredStyle: UIAlertControllerStyleAlert];
- UIAlertAction *action_back = [UIAlertAction actionWithTitle:@"Back" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf.navigationController popViewControllerAnimated:false];
- }];
- UIAlertAction *action_reload = [UIAlertAction actionWithTitle:@"Reload" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf ReloadData];
- }];
- [alertVC addAction:action_back];
- [alertVC addAction:action_reload];
- [weakSelf presentViewController:alertVC animated:YES completion:nil];
- }
- else
- if([self.content get_segmentcount]==0)
- {
-
-
- self.table.hidden =true;
- self.norecordLabel.hidden=false;
-
- if(self.tabBarController.childViewControllers.count==1)
- {
- UIAlertController *alertVC = [UIAlertController alertControllerWithTitle: @"Warning"
- message: @"No Search Result."
- preferredStyle: UIAlertControllerStyleAlert];
- UIAlertAction *action = [UIAlertAction actionWithTitle:@"Back" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf.navigationController popViewControllerAnimated:false];
- }];
- [alertVC addAction:action];
- [weakSelf presentViewController:alertVC animated:YES completion:nil];
-
- }
-
-
- }
- else
- {
-
- self.page_menu = result[@"page_menu"];
- self.table.hidden =false;
- [self.table reloadData];
-
- self.email = [self.content.originContent objectForKey:@"email"];
- self.email_subject = [self.content.originContent objectForKey:@"email_subject"];
- self.email_content = [self.content.originContent objectForKey:@"email_content"];
- }
- [UIView commitAnimations];
-
- // NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
- // bool autologin =[defaults boolForKey:@"autologin"];
- // if(!autologin)
- // {
- // TabBarController * viewController =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginTabBar"];
- // [self presentViewController:viewController animated:YES completion:^{
- //
- // }];
- // }
- // 设置默认选中第一个Container
- for (NSInteger i = 0; i < self.content.segments.count; i++) {
-
- NSMutableDictionary* segment = [self.content.segments[i] mutableCopy];
- NSString* type =[segment valueForKey:@"_type"];
-
- // if([type isEqualToString:@"tracking"]) {
- // NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:i];
- // [self.table selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
- // [self tableView:self.table didSelectRowAtIndexPath:indexPath];
- // break;
- // }
- }
- }];
-
-
-
- return;
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // self.content=[RANetwork get_detailcontent:self.params];
- //
- //
- // // PageData* pageData=nil;
- // // if(self.recordCount==-1)
- // // self.recordCount=[RANetwork get_recordcount: self.params ];
- // // if(self.recordCount>0)
- // // {
- // // self.pageData=[RANetwork get_pagedata:self.params];
- // // // self.pageData=[RANetwork]
- // // }
- // //
- // dispatch_async(dispatch_get_main_queue(), ^{
- //
- //
- // NSTimeInterval animationDuration = 0.30f;
- // [UIView beginAnimations:@"ResizeView" context:nil];
- // [UIView setAnimationDuration:animationDuration];
- //
- //
- // self.mum.hidden = true;
- // if(self.content.result_code!=RESULT_TRUE)
- // {
- // self.table.hidden =false;
- // [self.table reloadData];
- //
- // }
- // else
- // if([self.content get_segmentcount]==0)
- // {
- //
- //
- // self.table.hidden =true;
- // self.norecordLabel.hidden=false;
- //
- // if(self.tabBarController.childViewControllers.count==1)
- // {
- // UIAlertController *alertVC = [UIAlertController alertControllerWithTitle: @"Warning"
- // message: @"No Search Result."
- // preferredStyle: UIAlertControllerStyleAlert];
- // UIAlertAction *action = [UIAlertAction actionWithTitle:@"Back" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- // [weakSelf.navigationController popViewControllerAnimated:false];
- // }];
- // [alertVC addAction:action];
- // [weakSelf presentViewController:alertVC animated:YES completion:nil];
- //
- // }
- //
- //
- //
- // }
- // else
- // {
- // self.table.hidden =false;
- // [self.table reloadData];
- //
- // self.email = [self.content.originContent objectForKey:@"email"];
- // self.email_subject = [self.content.originContent objectForKey:@"email_subject"];
- // self.email_content = [self.content.originContent objectForKey:@"email_content"];
- // }
- // [UIView commitAnimations];
- //
- // NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
- // bool autologin =[defaults boolForKey:@"autologin"];
- // if(!autologin)
- // {
- // TabBarController * viewController =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginTabBar"];
- // [self presentViewController:viewController animated:YES completion:^{
- //
- // }];
- // }
- // // 设置默认选中第一个Container
- // for (NSInteger i = 0; i < self.content.segments.count; i++) {
- //
- // NSMutableDictionary* segment = [self.content.segments[i] mutableCopy];
- // NSString* type =[segment valueForKey:@"_type"];
- //
- // if([type isEqualToString:@"tracking"]) {
- // NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:i];
- // [self.table selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
- // [self tableView:self.table didSelectRowAtIndexPath:indexPath];
- // break;
- // }
- // }
- //
- // // [self.table setNeedsDisplay];
- // // if(self.recordCount<2000)
- // // self.countView.title = [NSString stringWithFormat:@"%d records",self.recordCount];
- // // else
- // // self.countView.title = @"2000+ records";
- // //
- // // if(self.offset<self.pageData.get_count)
- // // self.prepageButton.enabled=false;
- // // else
- // // self.prepageButton.enabled=true;
- // // if(self.offset+self.pageData.get_count>=self.recordCount)
- // // self.nextpageButton.enabled=false;
- // // else
- // // self.nextpageButton.enabled=true;
- // // [self.grid initgrid :self.pageData];
- //
- //
- // });
- // });
- }
- //- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
- //{
- //// [self.table beginUpdates];
- // [self.table reloadData];
- //// [self.table endUpdates];
- //
- //}
- - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
-
- __weak typeof(self) weakSelf = self;
- [coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
-
- // 动画前
- } completion:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
-
- // 动画后
- [weakSelf.table reloadData];
- }];
-
- [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
- }
- //// 是否支持屏幕旋转
- //- (BOOL)shouldAutorotate {
- //
- //
- // return YES;
- //}
- //// 支持的旋转方向
- //- (NSUInteger)supportedInterfaceOrientations {
- // return UIInterfaceOrientationLandscapeRight;//UIInterfaceOrientationMaskAllButUpsideDown;
- //}
- //// 一开始的屏幕旋转方向
- //- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
- // return UIInterfaceOrientationLandscapeRight;
- //}
- - (void)showDocument:(NSString *)url {
-
- __weak typeof(self) weakSelf = self;
-
- // show alert
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle: nil
- message: @"loading..."
- preferredStyle: UIAlertControllerStyleAlert];
-
-
-
- UIViewController *customVC = [[UIViewController alloc] init];
-
-
- UIActivityIndicatorView* spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
- spinner.color = [UIColor darkGrayColor];
- [spinner startAnimating];
- [customVC.view addSubview:spinner];
-
- [customVC.view addConstraint:[NSLayoutConstraint
- constraintWithItem: spinner
- attribute:NSLayoutAttributeCenterX
- relatedBy:NSLayoutRelationEqual
- toItem:customVC.view
- attribute:NSLayoutAttributeCenterX
- multiplier:1.0f
- constant:0.0f]];
-
-
-
- [customVC.view addConstraint:[NSLayoutConstraint
- constraintWithItem: spinner
- attribute:NSLayoutAttributeCenterY
- relatedBy:NSLayoutRelationEqual
- toItem:customVC.view
- attribute:NSLayoutAttributeCenterY
- multiplier:1.0f
- constant:0.0f]];
-
-
- [alertController setValue:customVC forKey:@"contentViewController"];
-
- [self presentViewController: alertController animated: YES completion: nil];
-
- // NSString *cacheDir = NSTemporaryDirectory();
- [RADataProvider DownloadFile:nil url:url completionHandler:^(NSMutableDictionary *result) {
- // [RANetwork request_download:nil url:url err_record_url:nil offset:0 method:nil storein:cacheDir progressHandler:nil completionHandler:^(NSMutableDictionary *result) {
- weakSelf.documentPath = nil;
- [alertController dismissViewControllerAnimated:YES completion:^{
-
-
- if ([[result objectForKey:@"result"] intValue] == RESULT_TRUE) {
-
- NSString *cachePath = [result objectForKey:@"path"];
- weakSelf.documentPath = cachePath;
-
- if (cachePath) { // push 必须在completion中
- [weakSelf.navigationController pushViewController:weakSelf.quickLook animated:YES];
- }
-
- } else {
-
- NSString *msg = [result objectForKey:@"msg"];
-
- UIAlertController *alertVC = [UIAlertController alertControllerWithTitle: @"Warning"
- message: msg
- preferredStyle: UIAlertControllerStyleAlert];
- UIAlertAction *action = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alertVC addAction:action];
- [weakSelf presentViewController:alertVC animated:YES completion:nil];
- }
-
- }];
- }];
-
- // [RANetwork request_download:nil url:url completionHandler:^(NSMutableDictionary *result) {
- //
- //
- // }];
-
- //
- // // download
- // dispatch_async(dispatch_get_global_queue(0, 0), ^{
- //
- // // NSArray *paths = NSSearchPathForDirectoriesInDomains(nstem, NSUserDomainMask, YES);
- // // NSString *documents = [paths objectAtIndex:0];
- // // NSString *cacheDir = [documents stringByAppendingPathComponent:[module_name stringByAppendingString:@"_download"]];
- //
- // NSString *cacheDir = NSTemporaryDirectory();
- //
- // if (![[NSFileManager defaultManager] fileExistsAtPath:cacheDir]) {
- // [[NSFileManager defaultManager] createDirectoryAtPath:cacheDir withIntermediateDirectories:NO attributes:nil error:nil];
- // }
- //
- // // NSString *path = [cacheDir stringByAppendingPathComponent:[NSUUID UUID].UUIDString];
- //
- //
- //
- // [RANetwork download_file:nil url:url toCachePath:cacheDir progressHandler:^(NSURLSessionTask *task, double progress) {
- //
- // DebugLog(@"download progress %f",progress);
- // } completionHandler:^(NSMutableDictionary *result) {
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- //
- // weakSelf.documentPath = nil;
- // [alertController dismissViewControllerAnimated:YES completion:^{
- //
- //
- // if ([[result objectForKey:@"result"] intValue] == RESULT_TRUE) {
- //
- // NSString *cachePath = [result objectForKey:@"path"];
- // weakSelf.documentPath = cachePath;
- //
- // if (cachePath) { // push 必须在completion中
- // [weakSelf.navigationController pushViewController:weakSelf.quickLook animated:YES];
- // }
- //
- // } else {
- //
- // NSString *msg = [result objectForKey:@"msg"];
- //
- // UIAlertController *alertVC = [UIAlertController alertControllerWithTitle: @"Warning"
- // message: msg
- // preferredStyle: UIAlertControllerStyleAlert];
- // UIAlertAction *action = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- //
- // }];
- // [alertVC addAction:action];
- // [weakSelf presentViewController:alertVC animated:YES completion:nil];
- // }
- //
- // }];
- //
- //
- // });
- //
- // DebugLog(@"download result %@",result);
- //
- // }];
- //
- //
- // });
-
- }
- #pragma mark - WKNavigationDelegate
- - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
- {
- NSLog(@"webview didFinishNavigation");
- UITableViewCell *cell = (UITableViewCell *)[[webView superview] superview];
-
-
- NSIndexPath *indexPath = [self.table indexPathForCell:cell];
- if(indexPath==nil)
- {//for ios7
- cell = (UITableViewCell *) webView.superview.superview.superview;
- indexPath = [self.table indexPathForCell:cell];
- }
-
-
-
- float height= [[self.content.webviewHeight valueForKey:[NSString stringWithFormat:@"%ld",(long)indexPath.section]] floatValue];
-
- if(height>0)
- return;
-
-
-
- [webView evaluateJavaScript:@"document.body.scrollHeight;" completionHandler:^(id _Nullable fitHeight,NSError * _Nullable error) {
- CGRect frame = webView.frame;
- frame.size.height = [fitHeight floatValue];
- //webView.frame = frame;
-
- [self.content.webviewHeight setObject:[NSString stringWithFormat:@"%f",frame.size.height/*webView.scrollView.contentSize.height*/] forKey:[NSString stringWithFormat:@"%ld",(long)indexPath.section]];
-
- DebugLog(@"webViewDidFinishLoad ^^^^^^^^^^^^^^^^^reloadRowsAtIndexPaths");
- if (![[self.table indexPathsForVisibleRows] containsObject:indexPath])
- {
- //cell 已无法显示。
- return;
- }
-
- dispatch_async(dispatch_get_main_queue(), ^{
-
-
- NSLog(@"reload tableview!!! %f",frame.size.height);
- // UI更新代码
- // [self.table reloadData];
- // [self.detailTable reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
- [self.table reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
- //[self.editorTable reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
- });
-
-
- }];
-
-
- }
- //禁止链接跳转
- - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
-
- NSLog(@"%s",__func__);
- NSLog(@"navigationAction = %@, \r!!!!!!!!!!!!!!!!!!!!!!\n request = %@",navigationAction,navigationAction.request.URL);
-
-
-
-
-
- if(navigationAction.navigationType != WKNavigationTypeLinkActivated)
-
- return decisionHandler(WKNavigationActionPolicyAllow);
- // NSString *currentURL =[webView.request.URL lastPathComponent];// [webView stringByEvaluatingJavaScriptFromString:@"document.title"];
- NSString* str = navigationAction.request.URL.absoluteString;
- if([str isEqualToString:@"about:blank"])
- return decisionHandler(WKNavigationActionPolicyAllow);;
-
- [self showDocument:navigationAction.request.URL.absoluteString];
-
- return decisionHandler(WKNavigationActionPolicyCancel);;
-
-
- }
- #pragma mark - Section Switch
- - (void)sectionSwitchClick:(UIButton *)sender {
- NSInteger section = sender.tag - 1020;
-
- NSMutableArray *segments = [self.content.segments mutableCopy];
- NSMutableDictionary* segment = [self.content.segments[section] mutableCopy];
- NSString* type =[segment valueForKey:@"_type"];
- // if([type isEqualToString:@"tracking"])
- // {
- // BOOL close = [[segment objectForKey:@"close"] boolValue];
- //
- // if (!close) {
- // close = YES;
- // } else {
- // close = NO;
- // }
- // [segment setValue:@(close) forKey:@"close"];
- // segments[section] = segment;
- // self.content.segments = segments;
- //// [self.table reloadSections:[NSIndexSet indexSetWithIndex:section] withRowAnimation:UITableViewRowAnimationNone];
- // [self.table reloadData];
- // }
- }
- - (void)copyTap:(UITapGestureRecognizer *)tap {
- UILabel *lb = (UILabel *)tap.view;
-
- UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
- pasteboard.string = lb.text;
- [DetailHUD show:[NSString stringWithFormat:@"%@ Copied",lb.text] inView:self.view];
- }
- #pragma mark - Table view data source
- //
- //- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
- //{
- // return 40;
- //}
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
- {
- DebugLog(@"heightForRowAtIndexPath");
-
- // float height = [self.content itemHeightAtIndexPath:indexPath];
- NSString* type = [self.content get_segmenttype:indexPath.section];
-
-
-
- if([type isEqualToString:@"table"])
- {
- // [self.content.webviewHeight setObject:[NSString stringWithFormat:@"%f",webView.frame.size.height] forKey:[NSString stringWithFormat:@"%d",webView.tag]];
-
- float height= [[self.content.webviewHeight valueForKey:[NSString stringWithFormat:@"%ld",(long)indexPath.section]] floatValue];
- if(height==0)
- height=DEF_TABLE_HEIGHT;
-
-
- // DebugLog(@"heightForRowAtIndexPath...............webview,hight = %f section=%ld",height,indexPath.section);
- //wait(1000);
- return height;
-
- }
- // else if([type isEqualToString:@"tracking"])
- // {
- // return 64;
- // }
- else if([type isEqualToString:@"container"])
- {
- return 100;
- }
- else if([type isEqualToString:@"container_ca"])
- {
- return 48;
- }
-
- else if([type isEqualToString:@"mapping"])
- {
-
-
- // NSString *CellIdentifier = @"detail_item_kvnew";
- // DetailCellKVNew *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- NSDictionary* item = [self.content get_item_seg:indexPath.section row:indexPath.row];
- NSString* key =[item allKeys][0];
- // [cell.keyLabel sizeToFit];
- NSString* val=[item valueForKey:key];
- if([val isEqual:[NSNull null]])
- val=@"";
- // cell.keyLabel.text = key;
- // cell.valLabel.htmlText = val;
-
- // UILabel* l = [UILabel new];
- // l.text =@"Place_Of_Receipt";
-
- // CGSize size= [l sizeThatFits:CGSizeMake(116,MAXFLOAT)];
-
- float width = tableView.frame.size.width;
- // width-=CELL_MARGIN*2;
- CGSize constraintkey = CGSizeMake(width*0.4-2*NEW_MAPCELL_MARGIN, MAXFLOAT);//key label width is 40% cell width;
- CGSize constraintval = CGSizeMake(width*0.6-2*NEW_MAPCELL_MARGIN, MAXFLOAT);//val label width is 60% cell width;
-
- /*
- NSLineBreakByWordWrapping = 0, // Wrap at word boundaries, default
- NSLineBreakByCharWrapping, // Wrap at character boundaries
- NSLineBreakByClipping, // Simply clip
- NSLineBreakByTruncatingHead, // Truncate at head of line: "...wxyz"
- NSLineBreakByTruncatingTail,
- */
-
- UIFont * F1=[UIFont systemFontOfSize:13];
- UIFont * F2=[UIFont fontWithName:@".SFUIText-Bold" size:13];//[UIFont boldSystemFontOfSize:13];
- // [UILabel setFont:];
- MDHTMLLabel* keylabel = [MDHTMLLabel new];
- keylabel.font = F2;
- keylabel.numberOfLines = 0;
- keylabel.lineBreakMode = NSLineBreakByTruncatingTail;
- keylabel.frame = CGRectMake(0, 0, constraintkey.width, constraintkey.height);
- keylabel.text=key;
- CGSize calkeysize= [keylabel sizeThatFits:constraintkey];
- if([key isEqualToString:@"Place_Of_Delivery"])
- {
- // int abc=0;
- }
- // [keylabel sizeToFit];
- // CGRect r = keylabel.frame;
-
-
- MDHTMLLabel* vallabel = [MDHTMLLabel new];
- vallabel.font = F1;
- vallabel.numberOfLines = 0;
- vallabel.lineBreakMode = NSLineBreakByWordWrapping;
- vallabel.htmlText=val;
- vallabel.frame = CGRectMake(0, 0, constraintval.width, constraintval.height);
- CGSize calvalsize= [vallabel sizeThatFits:constraintval];
-
- float height = MAX(calkeysize.height,calvalsize.height)+NEW_MAPCELL_MARGIN*2;
- height = MAX(height+LINE_WIDTH, DEF_CELL_HEIGHT);
-
- return height;
- //
- // NSDictionary* item = [self.content get_item_seg:indexPath.section row:indexPath.row];
- // NSString* key =[item allKeys][0];
- // // [cell.keyLabel sizeToFit];
- // NSString* val=[item valueForKey:key];
- // if([val isEqual:[NSNull null]])
- // val=@"";
- // if(val==nil)
- // val=@"";
- // if([val isEqualToString:@"null"])
- // val=@"";
- //
- //
- //
- // CGRect frame;
- // frame.size = constraintval;
- // frame.origin.x=0;
- // frame.origin.y=0;
- // RTLabel* rtlabel = [[RTLabel alloc] initWithFrame:frame];
- // [rtlabel setLineBreakMode: RTTextLineBreakModeWordWrapping];
- // // rtlabel.lineSpacing = 20.0;
- // [rtlabel setText: val];
- // CGSize sizeval=rtlabel.optimumSize;
- //
- //
- // CGSize sizekey = [key sizeWithFont:[UIFont systemFontOfSize:17.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
- // // CGSize sizeval = [val sizeWithFont:[UIFont systemFontOfSize:17.0] constrainedToSize:constraintval lineBreakMode:NSLineBreakByWordWrapping];
- // float height = MAX(sizekey.height,sizeval.height);
- // height = MAX(height+LINE_WIDTH, DEF_CELL_HEIGHT);
- //
- // /*
- // NSString *text = [items objectAtIndex:[indexPath row]];
- //
- // CGSize constraint = CGSizeMake(CELL_CONTENT_WIDTH - (CELL_CONTENT_MARGIN * 2), 20000.0f);
- //
- // CGSize size = [text sizeWithFont:[UIFont systemFontOfSize:FONT_SIZE] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
- //
- // CGFloat height = MAX(size.height, 44.0f);
- //
- // return height + (CELL_CONTENT_MARGIN * 2);
- // */
- // // NSString *CellIdentifier = @"detail_item_kv";
- // // DetailCellKV *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- // // NSDictionary* item = [self.content get_item_seg:indexPath.section row:indexPath.row];
- // // cell.keyLabel.text=[item allKeys][0];
- // // [cell.keyLabel sizeToFit];
- // // cell.valLabel.text= [item valueForKey:cell.keyLabel.text];
- // // [cell.valLabel sizeToFit];
- // //
- // // return MAX(cell.keyLabel.frame.size.height,cell.valLabel.frame.size.height);
- // return height;
- }
- // else if ([type isEqualToString:@"communication"]) {
- // NSInteger rowCount = [self tableView:tableView numberOfRowsInSection:indexPath.section];
- // if (indexPath.row == 0) {
- // return 118.0f;
- // } else if (indexPath.row == rowCount - 1) {
- //
- // NSMutableDictionary* segment = [self.content.segments[indexPath.section] mutableCopy];
- // NSString *edit_content = [segment objectForKey:@"edit_content"];
- //
- // CGFloat h = 40.0f; // 输入框高度,最小40
- // if (edit_content && edit_content.length > 0) {
- //
- // AMCommEditCell *cell = [[[NSBundle mainBundle] loadNibNamed:@"AMCommEditCell" owner:nil options:nil] objectAtIndex:0];
- //
- // h = [cell heightForContent:edit_content withTableWidth:CGRectGetWidth(tableView.bounds)];
- //
- // if (h < 40.0f) {
- // h = 40.0f;
- // } else if (h > 100.0f) { // 输入框高度,最大100
- // h = 100.0f;
- // }
- //
- //
- // } else {
- // h = 40.0f;
- // }
- //
- // return 50.0f + h;
- // } else {
- //
- // NSMutableDictionary* segment = [self.content.segments[indexPath.section] mutableCopy];
- // NSString *itemKey = [NSString stringWithFormat:@"item%ld",indexPath.row - 1];
- // NSDictionary *item = [[segment objectForKey:itemKey] mutableCopy];
- //
- // CGFloat height = [[item objectForKey:@"content_height"] floatValue];
- // if (height <= 0) {
- //
- // NSString *content = [item objectForKey:@"msg"];
- //
- // if (content && content.length > 0) {
- // NSDictionary *attribute = @{NSFontAttributeName: [UIFont systemFontOfSize:14.0f]};
- //
- // CGSize resSize = [content boundingRectWithSize:CGSizeMake(CGRectGetWidth(tableView.bounds) - 11, MAXFLOAT)
- // options:(NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading)
- // attributes:attribute
- // context:nil].size;
- // height = resSize.height;
- // } else {
- // height = 0;
- // }
- //
- // [item setValue:@(height) forKey:@"content_height"];
- // [segment setObject:item forKey:itemKey];
- //
- // NSMutableArray *arr = [self.content.segments mutableCopy];
- // [arr replaceObjectAtIndex:indexPath.section withObject:segment];
- // self.content.segments = arr;
- // }
- //
- // return 71.5 + height;
- // }
- // }
- else if([type isEqualToString:@"log"])
- {
- DebugLog(@"cellForRowAtIndexPath =====> list");
-
- float width = tableView.frame.size.width;
- width-=CELL_MARGIN*2;
-
- CGSize constraintval = CGSizeMake(width, 20000.0f);//val label width is 60% cell width;
-
- NSDictionary* item = [self.content get_item_seg:indexPath.section row:indexPath.row];
-
- NSString* text=item[@"text"];
-
-
-
- if([text isEqual:[NSNull null]])
- text=@"";
- if(text==nil)
- text=@"";
- if([text isEqualToString:@"null"])
- text=@"";
-
-
-
- // CGRect frame;
- // frame.size = constraintval;
- // frame.origin.x=0;
- // frame.origin.y=0;
-
-
- // CGSize sizeText = [text sizeWithFont:[UIFont systemFontOfSize:13.0] constrainedToSize:constraintval lineBreakMode:NSLineBreakByWordWrapping];
- // CGSize sizeval = [val sizeWithFont:[UIFont systemFontOfSize:17.0] constrainedToSize:constraintval lineBreakMode:NSLineBreakByWordWrapping];
-
- CGSize sizeText = [text boundingRectWithSize:constraintval options:(NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading) attributes: @{NSFontAttributeName: [UIFont systemFontOfSize:13.0]} context:nil].size;
-
-
-
- // UILabel* label = [UILabel new];
- // label.frame= CGRectMake(0, 0, width, 2000.0f);
- //
- // label.font =[UIFont systemFontOfSize:13.0];
- //
- // CGSize bestsize=[label sizeThatFits:constraintval];
- float height = sizeText.height;
- height = MAX(height+LINE_WIDTH+LIST_VMARGIN, DEF_CELL_HEIGHT);
- return ceilf(height);
-
- }
- else
- {
- DebugLog(@"cellForRowAtIndexPath =====> list");
-
- float width = tableView.frame.size.width;
- width-=CELL_MARGIN*2;
-
- CGSize constraintval = CGSizeMake(width, 20000.0f);//val label width is 60% cell width;
-
- NSDictionary* item = self.content.segments[indexPath.section];
-
- NSString* text=[item valueForKey:[NSString stringWithFormat:@"line%ld",(long)indexPath.row]];
-
-
-
- if([text isEqual:[NSNull null]])
- text=@"";
- if(text==nil)
- text=@"";
- if([text isEqualToString:@"null"])
- text=@"";
-
-
-
- // CGRect frame;
- // frame.size = constraintval;
- // frame.origin.x=0;
- // frame.origin.y=0;
-
-
- // CGSize sizeText = [text sizeWithFont:[UIFont systemFontOfSize:13.0] constrainedToSize:constraintval lineBreakMode:NSLineBreakByWordWrapping];
- // CGSize sizeval = [val sizeWithFont:[UIFont systemFontOfSize:17.0] constrainedToSize:constraintval lineBreakMode:NSLineBreakByWordWrapping];
-
- CGSize sizeText = [text boundingRectWithSize:constraintval options:(NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading) attributes: @{NSFontAttributeName: [UIFont systemFontOfSize:13.0]} context:nil].size;
- float height = sizeText.height;
- height = MAX(height+LINE_WIDTH+LIST_VMARGIN, DEF_CELL_HEIGHT);
- return ceilf(height);
-
- }
-
-
- // return height;
- }
- //- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
- //{
- // UIView* myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 30)];
- // myView.backgroundColor = [UIColor colorWithRed:0.10 green:0.68 blue:0.94 alpha:0.7];
- // UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 90, 22)];
- // titleLabel.textColor=[UIColor whiteColor];
- // titleLabel.backgroundColor = [UIColor clearColor];
- // titleLabel.text =[self.content get_segmentname:section];
- // [titleLabel sizeToFit];
- // [myView addSubview:titleLabel];
- //
- // return myView;
- //}
- //- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
- //{
- // UIView* myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 30)];
- // myView.backgroundColor = [UIColor colorWithRed:0.10 green:0.68 blue:0.94 alpha:0.7];
- //// UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 90, 22)];
- //// titleLabel.textColor=[UIColor whiteColor];
- //// titleLabel.backgroundColor = [UIColor grayColor];
- //// titleLabel.text =[self.content get_segmentname:section];
- //// [titleLabel sizeToFit];
- //// [myView addSubview:titleLabel];
- //
- // return myView;
- //}
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
-
- DebugLog(@"numberOfSectionsInTableView=%ld",[self.content get_segmentcount]);
- return [self.content get_segmentcount];
-
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- DebugLog(@"numberOfRowsInSection=%d",[self.content get_itemcount:section]);
- NSMutableDictionary* segment = [self.content.segments[section] mutableCopy];
- NSString* type =[segment valueForKey:@"_type"];
-
- if ([type isEqualToString:@"communication"]) {
- return [self.content get_itemcount:section] + 2;
- } else {
- return [self.content get_itemcount:section];
- }
-
-
- }
- - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
- DebugLog(@"titleForHeaderInSection=%@",[self.content get_segmentname:section]);
- return [self.content get_segmentname:section];
- }
- - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
-
- NSMutableDictionary* segment = [self.content.segments[section] mutableCopy];
- NSString* type =[segment valueForKey:@"_type"];
- CGFloat w = tableView.frame.size.width;
- UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, w, 30)];
-
- UILabel *titleLb = [[UILabel alloc] initWithFrame:CGRectMake(5, 0, w - 100, 30)];
- titleLb.font = [UIFont systemFontOfSize:15.0f];
- titleLb.textColor = APGRAYCOLOR;
- titleLb.text = [self tableView:tableView titleForHeaderInSection:section];
-
- [header addSubview:titleLb];
-
- // if([type isEqualToString:@"tracking"])
- // {
- // BOOL close = [[segment objectForKey:@"close"] boolValue];
- // NSString *title = @"Show";
- // if (!close) {
- // title = @"Hide";
- // } else {
- // title = @"Show";
- // }
- //
- // UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
- // btn.frame = CGRectMake(w - 70, 0, 60, 30);
- // btn.tag = 1020 + section;
- // [btn setTitle:title forState:UIControlStateNormal];
- // [btn setTitleColor:APGRAYCOLOR forState:UIControlStateNormal];
- // [btn addTarget:self action:@selector(sectionSwitchClick:) forControlEvents:UIControlEventTouchUpInside];
- //
- // [header addSubview:btn];
- //
- // // Tap Copy
- // UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(copyTap:)];
- // tapGesture.numberOfTapsRequired = 2;
- // [titleLb addGestureRecognizer:tapGesture];
- // titleLb.userInteractionEnabled = YES;
- // }
-
- return header;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- {
- return 30;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
- {
- return 0.0001;
- }
- //- (UIImage *) imageWithTintColor:(UIImage*)source Color:(UIColor *)tintColor blendMode:(CGBlendMode)blendMode {
- // //We want to keep alpha, set opaque to NO; Use 0.0f for scale to use the scale factor of the device’s main screen.
- // UIGraphicsBeginImageContextWithOptions(source.size, NO, 0.0f); [tintColor setFill];
- // CGRect bounds = CGRectMake(0, 0, source.size.width, source.size.height); UIRectFill(bounds);
- // //Draw the tinted image in context
- // [source drawInRect:bounds blendMode:blendMode alpha:1.0f];
- // if (blendMode != kCGBlendModeDestinationIn)
- // {
- // [source drawInRect:bounds blendMode:kCGBlendModeDestinationIn alpha:1.0f];
- // }
- // UIImage *tintedImage = UIGraphicsGetImageFromCurrentImageContext();
- // UIGraphicsEndImageContext();
- // return tintedImage;
- //}
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
-
-
-
- // NSString *CellIdentifier = @"testcell";
- // return [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
-
- NSString* type = [self.content get_segmenttype:indexPath.section];
-
-
-
- if([type isEqualToString:@"table"])
- {
- DebugLog(@"cellForRowAtIndexPath =====> table");
-
- static NSString *CellIdentifier = @"detail_item_web";
-
- DetailCellWeb *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- NSDictionary* item = [self.content get_item_seg:indexPath.section row:indexPath.row];
- NSString* tablecontent = [item valueForKey:@"content"];
- cell.webView.tag = indexPath.section;
- // cell.webView.scrollView.contentSize.height = 0;
- cell.webView.scrollView.bounces=NO;
- cell.webView.scrollView.directionalLockEnabled = true;
- CGSize size= cell.webView.scrollView.contentSize;
- size.height=10;
- cell.webView.scrollView.contentSize=size;
- cell.webView.navigationDelegate=self;
- // nsstring* c = [NSString stringwith]
- // NSString *filePath = [[NSBundle mainBundle]pathForResource:@"about" ofType:@"htm"];
- // NSString *htmlString = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
-
-
- [cell.webView loadHTMLString:tablecontent baseURL:nil];
- // dispatch_async(dispatch_get_main_queue(), ^{
- //
- // wait(5000);
- // DebugLog(@"!!!!!!!!!!!!!!!!!!!!!!!!!!!webview section=%ld height=%f",indexPath.section,cell.webView.scrollView.contentSize.height);
- //
- //// DebugLog(@"url:%@", [self.webView stringByEvaluatingJavaScriptFromString:@"window.location.href;"]); // shows google.com instead of about:blank
- // });
-
-
-
- // CGRect rect = cell.webView.frame;
- // [self.content set_itemheight:cell.webView.frame.size.height AtIndexPath:indexPath];
- // [cell.webView loadHTMLString:htmlString baseURL:[NSURL URLWithString:filePath]];
- return cell;
- }
- // else if([type isEqualToString:@"tracking"])
- // {
- // DebugLog(@"cellForRowAtIndexPath =====> table");
- //
- // static NSString *CellIdentifier = @"detail_item_tracking";
- //
- // DetailCellTracking *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- // NSDictionary* item = [self.content get_item_seg:indexPath.section row:indexPath.row];
- //
- // if(indexPath.row==0)
- // {
- // cell.trackingIcon.tintColor=UIColorFromRGB(0x1e7ffb);
- // cell.trackingIcon.image = [[UIImage imageNamed:item[@"icon"]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
- // }
- // else
- // {
- // cell.trackingIcon.tintColor=[UIColor grayColor];
- // cell.trackingIcon.image = [[UIImage imageNamed:item[@"icon"]] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
- // }
- //
- //
- // cell.trackingMsg.text=item[@"msg"];
- //// NSString* tablecontent = [item valueForKey:@"content"];
- //// cell.webView.tag = indexPath.section;
- //// // cell.webView.scrollView.contentSize.height = 0;
- //// cell.webView.scrollView.bounces=NO;
- //// cell.webView.scrollView.directionalLockEnabled = true;
- //// CGSize size= cell.webView.scrollView.contentSize;
- //// size.height=10;
- //// cell.webView.scrollView.contentSize=size;
- ////
- ////
- //// [cell.webView loadHTMLString:tablecontent baseURL:nil];
- //
- // return cell;
- // }
- else if([type isEqualToString:@"container"])
- {
-
-
- NSString *CellIdentifier = @"detail_item_container";
- DetailCellContainer *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- NSDictionary* item = [self.content get_item_seg:indexPath.section row:indexPath.row];
- cell.labelCMB.text = item[@"cmb"];
- cell.labelQTY.text = item[@"qty"];
- cell.labelWeight.text = item[@"weight"];
- cell.labelSize.text = item[@"size"];
- cell.labelContainerNo.text = item[@"container#"];
- cell.labelService.text=item[@"service"];
- cell.labelSealNo.text=item[@"seal_no"];
-
- //cell.tapDelegate = self;
-
- // UIView * lineview = [[LineView alloc] initWithFrame:cell.contentView.frame];
- // lineview.userInteractionEnabled = NO;// 不设为NO会屏蔽cell的点击事件
- // lineview.backgroundColor = [UIColor clearColor];// 设为透明从而使得cell.backgroundColor有效.
- // lineview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
- // [cell.contentView addSubview:lineview];// cell.contentView是个readonly属性,所以别想着替换contentView了.
- return cell;
- }
- else if([type isEqualToString:@"container_ca"])
- {
-
-
- NSString *CellIdentifier = @"detail_item_container_ca";
- DetailCellContainerCA *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- NSDictionary* item = [self.content get_item_seg:indexPath.section row:indexPath.row];
- cell.labelContainerNo.text = item[@"container#"];
- cell.labelSealNo.text=item[@"seal_no"];
-
- //cell.tapDelegate = self;
-
- // UIView * lineview = [[LineView alloc] initWithFrame:cell.contentView.frame];
- // lineview.userInteractionEnabled = NO;// 不设为NO会屏蔽cell的点击事件
- // lineview.backgroundColor = [UIColor clearColor];// 设为透明从而使得cell.backgroundColor有效.
- // lineview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
- // [cell.contentView addSubview:lineview];// cell.contentView是个readonly属性,所以别想着替换contentView了.
- return cell;
- }
- else if([type isEqualToString:@"mapping"])
- {
-
-
- NSString *CellIdentifier = @"detail_item_kvnew";
- DetailCellKVNew *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- NSDictionary* item = [self.content get_item_seg:indexPath.section row:indexPath.row];
- NSString* key =[item allKeys][0];
- // [cell.keyLabel sizeToFit];
- NSString* val=[item valueForKey:key];
-
- // if([val isEqual:[NSNull null]])
- // val=@"";
- cell.keyLabel.text = key;
- cell.valLabel.htmlText = val;
-
- // if([key isEqualToString:@"Place_Of_Delivery"])
- // {
- //// int abc=0;
- // }
-
- NSLog(@"key %@ val %@",key,val);
-
- cell.tapDelegate = self;
-
- // UIView * lineview = [[LineView alloc] initWithFrame:cell.contentView.frame];
- // lineview.userInteractionEnabled = NO;// 不设为NO会屏蔽cell的点击事件
- // lineview.backgroundColor = [UIColor clearColor];// 设为透明从而使得cell.backgroundColor有效.
- // lineview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
- // [cell.contentView addSubview:lineview];// cell.contentView是个readonly属性,所以别想着替换contentView了.
- return cell;
- // float width = tableView.frame.size.width;
- //
- // width-=CELL_MARGIN*2;
- // CGSize constraintkey = CGSizeMake(width*0.4-2*LABEL_MARGIN, 20000.0f);//key label width is 40% cell width;
- // CGSize constraintval = CGSizeMake(width*0.6-2*LABEL_MARGIN, 20000.0f);//val label width is 60% cell width;
- // NSDictionary* item = [self.content get_item_seg:indexPath.section row:indexPath.row];
- // NSString* key =[item allKeys][0];
- // // [cell.keyLabel sizeToFit];
- // NSString* val=[item valueForKey:key];
- // if([val isEqual:[NSNull null]])
- // val=@"";
- // if(val==nil)
- // val=@"";
- // if([val isEqualToString:@"null"])
- // val=@"";
- //
- //
- //
- //
- // CGRect frame;
- // frame.size = constraintval;
- // frame.origin.x=0;
- // frame.origin.y=0;
- // RTLabel* rtlabel = [[RTLabel alloc] initWithFrame:frame];
- // [rtlabel setLineBreakMode: RTTextLineBreakModeWordWrapping];
- // // rtlabel.lineSpacing = 20.0;
- // [rtlabel setText: val];
- // CGSize sizeval=rtlabel.optimumSize;
- // CGSize sizekey = [key sizeWithFont:[UIFont systemFontOfSize:17.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
- // // CGSize sizeval = [val sizeWithFont:[UIFont systemFontOfSize:17.0] constrainedToSize:constraintval lineBreakMode:NSLineBreakByWordWrapping];
- //// DebugLog(@"tableView width:%f",width);
- ////
- //// DebugLog(@"key width= %f val width = %f",constraintkey.width,constraintval.width);
- //// DebugLog(@"key = %@ val = %@",key,val);
- // float height = MAX(sizekey.height,sizeval.height);
- // height = MAX(height, DEF_CELL_HEIGHT-LINE_WIDTH);
- // sizekey.height = height;
- // sizekey.width = constraintkey.width;
- // // sizeval.height = height;
- // sizeval.width =constraintval.width;
- //
- // NSString *CellIdentifier = @"detail_item_kv";
- // DetailCellKV *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- // if(cell==nil)
- // DebugLog(@"cell is nil.........................");
- //
- //
- // // CGRect framekey ;
- // // framekey.origin.x=CELL_MARGIN;
- // // framekey.origin.y=LINE_WIDTH;
- // // framekey.size = sizekey;
- // // UILabel* keyLabel = [[UILabel alloc]initWithFrame:framekey];
- // // keyLabel.lineBreakMode = NSLineBreakByWordWrapping;
- // // keyLabel.backgroundColor = [UIColor grayColor];
- // // keyLabel.text = key;
- // //
- // // CGRect frameval;
- // // frameval.origin.x=constraintkey.width+CELL_MARGIN;
- // // frameval.origin.y=LINE_WIDTH;
- // // frameval.size = sizeval;
- // //
- // // UILabel* valLabel = [[UILabel alloc]initWithFrame:frameval];
- // // valLabel.lineBreakMode = NSLineBreakByWordWrapping;
- // // valLabel.text = val;
- // //
- // // for(UIView* v in cell.contentView.subviews)
- // // {
- // // [v removeFromSuperview];
- // //
- // // }
- // //
- // // [cell.contentView addSubview:keyLabel];
- // // [cell.contentView addSubview:valLabel];
- //
- //
- // CGRect framekey = cell.keyLabel.frame;
- // framekey.origin.x=CELL_MARGIN+LABEL_MARGIN;
- // framekey.origin.y=LINE_WIDTH;
- // framekey.size = sizekey;
- // cell.keyLabel.frame = framekey;
- // cell.keyLabel.text=key;
- // CGRect frameval = cell.valLabel.frame;
- // frameval.origin.x=constraintkey.width+CELL_MARGIN+3*LABEL_MARGIN; //2 margin for key 1 margin for value self
- // frameval.origin.y=LINE_WIDTH;
- // frameval.size = sizeval;
- // cell.valLabel.frame = frameval;
- // // [cell.valLabel setTextAlignment:RTTextAlignmentCenter];
- // cell.valLabel.text= val;
- // CGPoint rcenter;
- // rcenter.x = width * 0.4+width * 0.6/2;
- // rcenter.y = height /2;
- // cell.valLabel.center=rcenter;
- //// cell.valLabel.backgroundColor =[UIColor redColor];
- //
- //// cell.contentView.superview.backgroundColor = [UIColor clearColor];
- //// cell.backgroundColor = [UIColor whiteColor];
- // UIView * lineview = [[LineView alloc] initWithFrame:cell.contentView.frame];
- // lineview.userInteractionEnabled = NO;// 不设为NO会屏蔽cell的点击事件
- // lineview.backgroundColor = [UIColor clearColor];// 设为透明从而使得cell.backgroundColor有效.
- // lineview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
- // [cell.contentView addSubview:lineview];// cell.contentView是个readonly属性,所以别想着替换contentView了.
- //
- //
- //
- // // [cell.valLabel sizeToFit];
- // // cell.anameLabel.text = [field valueForKey:@"aname"];
- // // [cell.anameLabel sizeToFit];
- // // DebugLog(@"cellForRowAtIndexPath%@",[field valueForKey:@"aname"]);
- // // Configure the cell...
- // // CGRect rect = cell.frame;
- // // [self.content set_itemheight:100 AtIndexPath:indexPath];
- // return cell;
- }
- // else if ([type isEqualToString:@"communication"]) {
- //
- // NSInteger rowCount = [tableView numberOfRowsInSection:indexPath.section];
- //
- // NSMutableDictionary* segment = [self.content.segments[indexPath.section] mutableCopy];
- //
- // if (indexPath.row == 0) { // head
- //
- // AMCommHeadCell *cell = [tableView dequeueReusableCellWithIdentifier:COMM_ID_HEAD forIndexPath:indexPath];
- //
- // NSString *to = [segment objectForKey:@"receipt"];
- // NSString *cc = [segment objectForKey:@"cc"];
- //
- // [cell setTo:to];
- // [cell setCc:cc];
- //
- // cell.delegate = self;
- //
- // return cell;
- //
- // } else if (indexPath.row == rowCount - 1) { // edit
- //
- // AMCommEditCell *cell = [tableView dequeueReusableCellWithIdentifier:COMM_ID_EDIT forIndexPath:indexPath];
- //
- // NSString *editContent = [segment objectForKey:@"edit_content"];
- // [cell setEmail:editContent];
- // cell.delegate = self;
- //
- // return cell;
- //
- // } else { // content
- //
- // AMCommContentCell *cell = [tableView dequeueReusableCellWithIdentifier:COMM_ID_CONTENT forIndexPath:indexPath];
- //
- // NSDictionary *item = [segment objectForKey:[NSString stringWithFormat:@"item%ld",indexPath.row - 1]];
- //
- // NSString *sender = [item objectForKey:@"Sender"];
- // NSString *content = [item objectForKey:@"msg"];
- // NSString *time = [item objectForKey:@"mst_time"];
- // NSString *email = [item objectForKey:@"email_url"];
- //
- //
- // [cell setSender:sender];
- // [cell setContent:content];
- // [cell setTime:time];
- // [cell setEmail:email];
- //
- // cell.delegate = self;
- //
- // return cell;
- //
- // }
- // }
- else if([type isEqualToString:@"log"])
- {
- DebugLog(@"cellForRowAtIndexPath =====> list");
-
- static NSString *CellIdentifier = @"detail_item_list";
-
-
-
- // float width = tableView.frame.size.width;
- //
- // width-=CELL_MARGIN*2;
- // CGSize constraintkey = CGSizeMake(width, 20000.0f);//key label width is 40% cell width;
-
- // NSDictionary* item = self.content.segments[indexPath.section];
-
- NSDictionary* item = [self.content get_item_seg:indexPath.section row:indexPath.row];
-
- NSString* val=item[@"text"];
-
- bool bg =[item[@"bg"] boolValue];
-
- if([val isEqual:[NSNull null]])
- val=@"";
- if(val==nil)
- val=@"";
- if([val isEqualToString:@"null"])
- val=@"";
-
-
-
-
- // CGSize sizeval = [val sizeWithFont:[UIFont systemFontOfSize:13.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
-
- // CGSize sizeval = [val boundingRectWithSize:constraintkey options:(NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading) attributes: @{NSFontAttributeName: [UIFont systemFontOfSize:13.0]} context:nil].size;
- //
- // float height = sizeval.height;
- // height = MAX(height, DEF_CELL_HEIGHT-LINE_WIDTH);
- // sizeval.height = height;
- // sizeval.width = constraintkey.width;
-
-
-
-
-
-
-
-
- //创建cell
- DetailCellList *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- // CGRect framekey = cell.listLabel.frame;
- // framekey.origin.x=CELL_MARGIN;
- // framekey.origin.y=LINE_WIDTH;
- // framekey.size = sizeval;
- // cell.listLabel.frame = framekey;
- cell.listLabel.text= val;
-
- if(bg)
- cell.contentView.backgroundColor = LogBGColor1;
- else
- cell.contentView.backgroundColor = LogBGColor0;
-
- return cell;
-
- }
- else
- {
- DebugLog(@"cellForRowAtIndexPath =====> list");
-
- static NSString *CellIdentifier = @"detail_item_list";
-
-
-
- // float width = tableView.frame.size.width;
- //
- // width-=CELL_MARGIN*2;
- // CGSize constraintkey = CGSizeMake(width, 20000.0f);//key label width is 40% cell width;
- //
- NSDictionary* item = self.content.segments[indexPath.section];
- NSString* val=[item valueForKey:[NSString stringWithFormat:@"line%ld",(long)indexPath.row]];
-
- if([val isEqual:[NSNull null]])
- val=@"";
- if(val==nil)
- val=@"";
- if([val isEqualToString:@"null"])
- val=@"";
-
-
-
-
-
- // CGSize sizeval = [val sizeWithFont:[UIFont systemFontOfSize:13.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
-
- // CGSize sizeval = [val boundingRectWithSize:constraintkey options:(NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading) attributes: @{NSFontAttributeName: [UIFont systemFontOfSize:13.0]} context:nil].size;
- //
- // float height = sizeval.height;
- // height = MAX(height, DEF_CELL_HEIGHT-LINE_WIDTH);
- // sizeval.height = height;
- // sizeval.width = constraintkey.width;
-
-
-
-
-
-
-
-
- //创建cell
- DetailCellList *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- // CGRect framekey = cell.listLabel.frame;
- // framekey.origin.x=CELL_MARGIN;
- // framekey.origin.y=LINE_WIDTH;
- // framekey.size = sizeval;
- // cell.listLabel.frame = framekey;
- cell.listLabel.text= val;
-
-
-
- return cell;
-
- }
- return nil;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
-
- NSMutableDictionary* segment = [self.content.segments[indexPath.section] mutableCopy];
- NSString* type =[segment valueForKey:@"_type"];
-
- NSDictionary* item = [self.content get_item_seg:indexPath.section row:indexPath.row];
- if(([type isEqualToString: @"container"]||[type isEqualToString: @"container_ca"])&& [item[@"commodity"] boolValue])
- {
-
- NSString* cid=[item[@"id"] stringValue];
-
- NSMutableDictionary* param =[NSMutableDictionary new];
- param[@"action"]=@"detail";
- param[@"sub_type"]=@"container";
- param[@"action_type"]=@"Container Detail";
- param[@"id"]= cid;
-
-
- UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"Detail" bundle:[NSBundle mainBundle]];
- DetailPageViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"DetailPageViewController"];
-
- vc.function_name = @"Container Detail";
- vc.params = param;
- [vc setTitle:@"Container Detail"];
-
-
- // ResultViewController *vc = [ResultViewController resultViewController:params];
- [self.navigationController pushViewController:vc animated:YES];
-
- }
- // NSString* port = self.content.originContent[@"backup_port"];
-
- // if([type isEqualToString:@"tracking"]) {
- // NSDictionary *location = [segment objectForKey:@"location"];
- // [self.shipMap showShipAnnotaion:location backupLocation:port];
- // self.containerSelectedIndexPath = indexPath;
- // }
-
-
- }
- #pragma mark - Quick Look
- - (MyQLPreviewController *)quickLook {
- if (!_quickLook)
- {
- _quickLook = [[MyQLPreviewController alloc] init];
- _quickLook.delegate = self;
- _quickLook.dataSource = self;
- }
- else
- {
- [_quickLook reloadData];
- }
- return _quickLook;
- }
- #pragma mark - QuickLook Data Source
- - (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)controller {
- return 1;
- }
- - (id <QLPreviewItem>) previewController:(QLPreviewController *)controller previewItemAtIndex:(NSInteger)index {
-
- return [NSURL fileURLWithPath:self.documentPath];
- }
- #pragma mark - QuickLook Delegate
- - (void) previewControllerDidDismiss:(QLPreviewController *)controller {
-
- }
- /**
- * 文件内部链接点击不进行外部跳转
- */
- - (BOOL) previewController:(QLPreviewController *)controller shouldOpenURL:(NSURL *)url forPreviewItem:(id<QLPreviewItem>)item {
- return NO;
- }
- #pragma mark - KVDetail Tap Delegate
- - (void)detailCell:(DetailCellKVNew *)cell doubleTapedForValue:(NSString *)value {
-
- // NSIndexPath *indexPath = [self.table indexPathForCell:cell];
- UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
- pasteboard.string = value;
- [DetailHUD show:[NSString stringWithFormat:@"%@ Copied",cell.keyLabel.text] inView:self.view];
-
- }
- #pragma mark - Quick Look Menu Action
- - (void)saveDocument {
-
- NSMutableDictionary *emailInfo = [NSMutableDictionary new];
- if (self.email.length==0) {
- self.email=@"";
-
- }
- if (self.email_subject.length==0) {
- self.email_subject=@"";
-
- }
- if (self.email_content.length==0) {
- self.email_content=@"";
-
- }
- [emailInfo setValue:self.email forKey:@"reciptions"];
- [emailInfo setValue:self.email_subject forKey:@"subject"];
- [emailInfo setValue:self.email_content forKey:@"content"];
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- NSString *path = [paths objectAtIndex:0];
- NSString *filePath = [path stringByAppendingPathComponent:[self.documentPath lastPathComponent]];
- NSString *emailPath = [path stringByAppendingPathComponent:[NSString stringWithFormat:@".%@",[[self.documentPath stringByDeletingPathExtension] lastPathComponent]]];
-
- NSError *err;
-
- if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
- [[NSFileManager defaultManager] removeItemAtPath:filePath error:nil];
- }
- [[NSFileManager defaultManager] moveItemAtPath:self.documentPath toPath:filePath error:&err];
-
- NSData* saved_email_data = [RAConvertor dict2data:emailInfo];
-
- [saved_email_data writeToFile:emailPath atomically:NO];
-
-
-
-
-
- UIAlertController *alertVC;
- UIAlertAction *action = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- if (err) {
- alertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:[NSString stringWithFormat:@"save document failed:\n%@",err.localizedDescription] preferredStyle:UIAlertControllerStyleAlert];
- } else {
- alertVC = [UIAlertController alertControllerWithTitle:nil message:@"Document Saved" preferredStyle:UIAlertControllerStyleAlert];
- }
- [alertVC addAction:action];
-
- [self presentViewController:alertVC animated:YES completion:nil];
- }
- - (void)shareDocument {
-
- return [self share_activity];
- }
- -(void) share_activity
- {
- // 设置分享内容
- // NSString *text = @"分享内容";
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- NSString *path = [paths objectAtIndex:0];
- NSString *filePath = [path stringByAppendingPathComponent:[self.documentPath lastPathComponent]];
-
- // 没有保存的情况
- if ([[NSFileManager defaultManager] fileExistsAtPath:self.documentPath]) {
- filePath = self.documentPath;
- }
-
- NSURL *url = [NSURL fileURLWithPath:filePath];
-
- NSArray *activityItems = @[url];
-
- LPShareActivity *share = [[LPShareActivity alloc] init];
- share.to = [self.email componentsSeparatedByString:@","];//@[@"676767@qq.com"];
- share.subject = self.email_subject;//@"test subject";
- share.body = self.email_content;// @"body";
- share.filePath = filePath;
- share.handle = ^(UIViewController *vc) {
- [self presentViewController:vc animated:YES completion:^{
- // [share activityDidFinish:YES];
- // ...
- }];
- };
-
- // 服务类型控制器
- UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:@[share]];
- // _activityViewController = activityViewController;
- // activityViewController.excludedActivityTypes = @[UIActivityTypeMail];
- activityViewController.modalInPopover = true;
- [self presentViewController:activityViewController animated:YES completion:nil];
-
- // 选中分享类型
- [activityViewController setCompletionWithItemsHandler:^(NSString * __nullable activityType, BOOL completed, NSArray * __nullable returnedItems, NSError * __nullable activityError){
-
- // 显示选中的分享类型
- NSLog(@"act type %@",activityType);
-
- if (completed) {
- NSLog(@"ok");
- }else {
- NSLog(@"not ok");
- }
-
- }];
- }
- - (void)quickLookMenuClick:(id)sender {
-
- UIAlertController *menuAlert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
-
- __weak typeof(self) weakSelf = self;
- UIAlertAction *saveAction = [UIAlertAction actionWithTitle:@"Save Document" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf saveDocument];
- }];
- UIAlertAction *shareAction = [UIAlertAction actionWithTitle:@"Share Document" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf shareDocument];
- }];
- UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
-
- // [menuAlert addAction:saveAction];
- [menuAlert addAction:shareAction];
- [menuAlert addAction:cancelAction];
-
- [self presentViewController:menuAlert animated:YES completion:nil];
- }
- //
- //#pragma mark - Keyboard
- //
- //- (void)startListenKeyboard {
- // NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
- // // 键盘通知
- // [notificationCenter addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
- // [notificationCenter addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
- // [notificationCenter addObserver:self selector:@selector(keyboardChangeFrame:) name:UIKeyboardDidChangeFrameNotification object:nil];
- //
- // UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapToHideKeyboard:)];
- // [self.view addGestureRecognizer:tap];
- // self.tap = tap;
- //}
- //
- //- (void)stopListenKeyboard {
- // NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
- // [notificationCenter removeObserver:self];
- //
- // [self.view removeGestureRecognizer:self.tap];
- //}
- //
- //- (void)tapToHideKeyboard:(UITapGestureRecognizer *)tap {
- // [self.view endEditing:YES];
- //}
- //
- ///**键盘隐藏*/
- //- (void)keyboardWillHide:(NSNotification *)notification {
- // NSLog(@"keyboard hide");
- // self.showKeyboard = NO;
- //}
- //
- ///**键盘显示*/
- //- (void)keyboardWillShow:(NSNotification *)notification {
- //
- //// NSTimeInterval duration = [[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue];
- //// CGRect begin = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue];
- //// CGRect end = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
- ////
- //// if (duration == 0) {
- //// duration = 0.25;
- //// }
- // NSLog(@"keyboard show");
- // self.showKeyboard = YES;
- //}
- //
- ///**在使用过程中切换键盘*/
- //- (void)keyboardChangeFrame:(NSNotification *)notification {
- //
- // NSLog(@"keyboard change frame");
- //
- // NSTimeInterval duration = [[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue];
- //// CGRect begin = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue];
- // CGRect end = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
- //
- // if (duration == 0) {
- // duration = 0.25;
- // }
- //
- // NSLayoutConstraint *bottom_constraint = nil;
- // for (NSLayoutConstraint *constraint in self.view.constraints) {
- // if ([constraint.identifier isEqualToString:@"table_bottom_constraint"]) {
- // bottom_constraint = constraint;
- // break;
- // }
- // }
- //
- // CGFloat tabBarY = CGRectGetMinY(self.tabBarController.tabBar.frame);
- //
- // CGFloat offset = tabBarY - CGRectGetMinY(end);
- // if (offset < 0) {
- // offset = 0;
- // }
- //
- // if (bottom_constraint) {
- // bottom_constraint.constant = offset;
- // [self.view layoutIfNeeded];
- //
- // if (self.editingIndexPath) {
- // [self.table scrollToRowAtIndexPath:self.editingIndexPath atScrollPosition:UITableViewScrollPositionNone animated:UITableViewRowAnimationNone];
- // }
- // }
- //
- // CGSize contentSize = self.table.contentSize;
- // CGPoint contentOffset = self.table.contentOffset;
- // offset = contentOffset.y - (contentSize.height - CGRectGetHeight(self.table.bounds));
- // if (offset > 0) {
- // contentOffset.y -= offset;
- // self.table.contentOffset = contentOffset;
- // }
- //
- //}
- //#pragma mark - COMM Head Delegate
- //
- //- (void)commHeadCell:(AMCommHeadCell *)cell didChangeCC:(NSString *)cc {
- //
- // NSIndexPath *indexPath = [self.table indexPathForCell:cell];
- //
- // [self cc:cc changedForIndexPath:indexPath];
- //}
- //
- //- (void)commHeadCell:(AMCommHeadCell *)cell didBeginEditing:(UITextField *)textField {
- // self.editingCell = cell;
- // self.editingIndexPath = [self.table indexPathForCell:cell];
- //}
- //
- //- (void)commHeadCell:(AMCommHeadCell *)cell didEndEditing:(UITextField *)textField {
- // self.editingCell = nil;
- // self.editingIndexPath = nil;
- //}
- //
- //- (void)commHeadCell:(AMCommHeadCell *)cell didClickContactButton:(UIButton *)button {
- //
- // self.contactSelectIndexPath = [self.table indexPathForCell:cell];
- //
- // CNContactPickerViewController *contactVC = [[CNContactPickerViewController alloc] init];
- // contactVC.delegate = self;
- //
- //
- // [self presentViewController:contactVC animated:YES completion:nil];
- //}
- //
- //#pragma mark - COMM Content Delegate
- //
- //- (void)commContentCell:(AMCommContentCell *)cell sendEmail:(NSString *)email {
- //
- //// MFMailComposeViewController *emailVC = [[MFMailComposeViewController alloc] init];
- //// if (!emailVC) {
- ////
- //// return;
- //// }
- //// [emailVC setMessageBody:[NSString stringWithFormat:@"<a>%@</a>",email] isHTML:YES];
- ////
- //// [self presentViewController:emailVC animated:YES completion:nil];
- //
- // NSURL *url = [NSURL URLWithString:email];
- // if ([[UIApplication sharedApplication] canOpenURL:url]) {
- // [[UIApplication sharedApplication] openURL:url];
- // }
- //
- //}
- //
- //#pragma mark - COMM Edit Delegate
- //
- //- (void)commEditCell:(AMCommEditCell *)cell clickToSendEmail:(NSString *)email {
- //
- // // 检查Email内容是否为空
- // if (!email || email.length == 0) {
- //
- // UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Warning" message:@"The communication message that will be sent is blank" preferredStyle:UIAlertControllerStyleAlert];
- // UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- //
- // }];
- // [alert addAction:okAction];
- // [self presentViewController:alert animated:YES completion:nil];
- // return;
- // }
- //
- // NSIndexPath *indexPath = [self.table indexPathForCell:cell];
- // NSMutableDictionary* segment = [self.content.segments[indexPath.section] mutableCopy];
- // NSString *cc = [segment objectForKey:@"cc"];
- // if (cc && cc.length > 0) {
- //
- // // 校验邮箱地址格式是否有效
- // NSArray *ccArr = [cc componentsSeparatedByString:@";"];
- // for (NSString *ccStr in ccArr) {
- // if (ccStr.length > 0) {
- // BOOL isEmail = [self validateEmail:ccStr];
- // if (!isEmail) {
- // UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Warning" message:@"The communication cc is not right" preferredStyle:UIAlertControllerStyleAlert];
- // UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- //
- // }];
- // [alert addAction:okAction];
- // [self presentViewController:alert animated:YES completion:nil];
- // return;
- // }
- // }
- // }
- //
- // // 校验通过
- //
- // }
- //
- // UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:@"send email" preferredStyle:UIAlertControllerStyleAlert];
- // [self presentViewController:alert animated:YES completion:nil];
- //
- // NSString *serialNo = [segment objectForKey:@"serial_no"];
- //
- // __weak typeof(self) weakSelf = self;
- //
- // [RANetwork request_sendemail:email CC:cc SerialNo:serialNo completionHandler:^(NSMutableDictionary *result) {
- // NSDictionary *sendResponse=result;
- // [alert dismissViewControllerAnimated:YES completion:^{
- //
- // if (weakSelf) {
- // __strong typeof(weakSelf) strongSelf = weakSelf;
- // int result = [[sendResponse objectForKey:@"result"] intValue];
- //
- // if (result == RESULT_TRUE) {
- //
- // } else {
- // NSString *msg = [sendResponse objectForKey:@"err_msg"];
- // if (msg == nil) {
- // msg = @"Sorry,something wrong";
- // }
- // UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:msg preferredStyle:UIAlertControllerStyleAlert];
- // UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- //
- // }];
- // [alert addAction:okAction];
- // [strongSelf presentViewController:alert animated:YES completion:nil];
- // }
- //
- // }
- //
- // }];
- // }];
- //
- // return;
- //
- // dispatch_async(dispatch_get_global_queue(0, 0), ^{
- // NSDictionary *sendResponse = [RANetwork sendEmail:email CC:cc SerialNo:serialNo];
- // dispatch_async(dispatch_get_main_queue(), ^{
- //
- // [alert dismissViewControllerAnimated:YES completion:^{
- //
- // if (weakSelf) {
- // __strong typeof(weakSelf) strongSelf = weakSelf;
- // int result = [[sendResponse objectForKey:@"result"] intValue];
- //
- // if (result == RESULT_TRUE) {
- //
- // } else {
- // NSString *msg = [sendResponse objectForKey:@"err_msg"];
- // if (msg == nil) {
- // msg = @"Sorry,something wrong";
- // }
- // UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:msg preferredStyle:UIAlertControllerStyleAlert];
- // UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- //
- // }];
- // [alert addAction:okAction];
- // [strongSelf presentViewController:alert animated:YES completion:nil];
- // }
- //
- // }
- //
- // }];
- //
- // });
- // });
- //
- //
- //}
- //
- //- (void)commEditCell:(AMCommEditCell *)cell didChangeEmail:(NSString *)email {
- // // 保存数据
- // NSIndexPath *indexPath = [self.table indexPathForCell:cell];
- //
- // NSMutableDictionary* segment = [self.content.segments[indexPath.section] mutableCopy];
- // if (email && email.length > 0) {
- // [segment setValue:email forKey:@"edit_content"];
- // } else {
- // [segment removeObjectForKey:@"edit_content"];
- // }
- //
- // NSMutableArray *arr = [self.content.segments mutableCopy];
- // [arr replaceObjectAtIndex:indexPath.section withObject:segment];
- // self.content.segments = arr;
- //
- // // 调用 tableView 的 beginUpdates 和 endUpdates,重新计算 cell 的高度
- // [self.table beginUpdates];
- // [self.table endUpdates];
- //
- // // 防止在输入的时候超出屏幕区域
- // CGRect frame = cell.frame;
- // if (CGRectGetMaxY(frame) > CGRectGetMaxY(self.table.bounds)) {
- // [self.table scrollRectToVisible:frame animated:NO];
- // }
- //}
- //
- //- (void)commEditCell:(AMCommEditCell *)cell didBeginEditing:(UITextView *)textView {
- // self.editingCell = cell;
- // self.editingIndexPath = [self.table indexPathForCell:cell];
- //}
- //
- //- (void)commEditCell:(AMCommEditCell *)cell didEndEditing:(UITextView *)textView {
- // self.editingCell = nil;
- // self.editingIndexPath = nil;
- //}
- //
- //#pragma mark - Contact Picker Delegate
- //
- //- (void)contactPickerDidCancel:(CNContactPickerViewController *)picker {
- //
- // self.contactSelectIndexPath = nil;
- //}
- //
- //- (void)contactPicker:(CNContactPickerViewController *)picker didSelectContact:(CNContact *)contact {
- //
- // [self handleSelectContact:contact];
- //
- // self.contactSelectIndexPath = nil;
- //}
- //
- //- (void)contactPicker:(CNContactPickerViewController *)picker didSelectContacts:(NSArray<CNContact *> *)contacts {
- //
- // for (CNContact *contact in contacts) {
- // [self handleSelectContact:contact];
- // }
- //
- // self.contactSelectIndexPath = nil;
- //}
- //
- //- (void)contactPicker:(CNContactPickerViewController *)picker didSelectContactProperty:(CNContactProperty *)contactProperty {
- //
- // self.contactSelectIndexPath = nil;
- //}
- //
- //- (void)contactPicker:(CNContactPickerViewController *)picker didSelectContactProperties:(NSArray<CNContactProperty *> *)contactProperties {
- //
- // self.contactSelectIndexPath = nil;
- //}
- //
- //#pragma mark - Utils
- //
- //- (BOOL)validateEmail:(NSString *)email {
- //
- // NSString *emailRegex =@"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
- //
- // NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
- //
- // return [emailTest evaluateWithObject:email];
- //}
- //
- //- (void)handleSelectContact:(CNContact *)contact {
- //
- // NSArray *emailArr = [contact emailAddresses];
- // for (CNLabeledValue *value in emailArr) {
- // if ([value.label isEqualToString:CNLabelWork]) {
- // [self appendCC:[NSString stringWithFormat:@"%@;",value.value] forIndexPath:self.contactSelectIndexPath];
- // [self.table reloadRowsAtIndexPaths:@[self.contactSelectIndexPath] withRowAnimation:UITableViewRowAnimationNone];
- // AMCommHeadCell *cell = [self.table cellForRowAtIndexPath:self.contactSelectIndexPath];
- // [cell beginEditing];
- // break;
- // }
- // }
- //
- //}
- //
- //- (void)appendCC:(NSString *)cc forIndexPath:(NSIndexPath *)indexPath {
- // if (indexPath == nil || cc == nil || cc.length == 0) {
- // return;
- // }
- // NSMutableDictionary* segment = [self.content.segments[indexPath.section] mutableCopy];
- // NSString *oldCC = [segment objectForKey:@"cc"];
- // if (oldCC == nil || oldCC.length == 0) {
- // oldCC = cc;
- // } else {
- // if ([[oldCC substringFromIndex:oldCC.length - 1] isEqualToString:@";"]) {
- // oldCC = [oldCC stringByAppendingString:cc];
- // } else {
- // oldCC = [oldCC stringByAppendingString:[NSString stringWithFormat:@";%@",cc]];
- // }
- // }
- //
- // [self cc:oldCC changedForIndexPath:indexPath];
- //}
- //
- //- (void)cc:(NSString *)cc changedForIndexPath:(NSIndexPath *)indexPath {
- // if (indexPath == nil) {
- // return;
- // }
- // NSMutableDictionary* segment = [self.content.segments[indexPath.section] mutableCopy];
- // if (cc && cc.length > 0) {
- // [segment setValue:cc forKey:@"cc"];
- // } else {
- // [segment removeObjectForKey:@"cc"];
- // }
- //
- // NSMutableArray *arr = [self.content.segments mutableCopy];
- // [arr replaceObjectAtIndex:indexPath.section withObject:segment];
- // self.content.segments = arr;
- //}
- //
- //#pragma mark - ShipMap Delegate
- //
- //- (void)shipMap:(AMShipMap *)shipMap tryToZoomIn:(BOOL)zoomIn {
- //
- // if (zoomIn) {
- //
- // NSArray *constraints = self.view.constraints;
- // NSLayoutConstraint *h_ratio_constraint = nil;
- //
- // for (NSLayoutConstraint *constraint in constraints) {
- // if (constraint.identifier && [constraint.identifier isEqualToString:@"ratio_constraint"]) {
- // h_ratio_constraint = constraint;
- // }
- // }
- //
- // if (h_ratio_constraint) {
- // [self.view removeConstraint:h_ratio_constraint];
- // }
- //
- // NSLayoutConstraint *table_h_constraint = [NSLayoutConstraint constraintWithItem:self.table
- // attribute:NSLayoutAttributeHeight
- // relatedBy:NSLayoutRelationEqual
- // toItem:nil
- // attribute:NSLayoutAttributeNotAnAttribute
- // multiplier:0
- // constant:0];
- // table_h_constraint.identifier = @"table_height";
- // [self.view addConstraint:table_h_constraint];
- //
- // } else {
- //
- // NSArray *constraints = self.view.constraints;
- // NSLayoutConstraint *h_constraint = nil;
- //
- // for (NSLayoutConstraint *constraint in constraints) {
- // if (constraint.identifier && [constraint.identifier isEqualToString:@"table_height"]) {
- // h_constraint = constraint;
- // }
- // }
- //
- // if (h_constraint) {
- // [self.view removeConstraint:h_constraint];
- // }
- //
- // float h_ratio = 0.5;
- // NSLayoutConstraint *h_ratio_constraint = [NSLayoutConstraint constraintWithItem:shipMap
- // attribute:NSLayoutAttributeHeight
- // relatedBy:NSLayoutRelationEqual
- // toItem:self.table
- // attribute:NSLayoutAttributeHeight
- // multiplier:h_ratio
- // constant:0];
- // h_ratio_constraint.identifier = @"ratio_constraint";
- //
- // [self.view addConstraint:h_ratio_constraint];
- // }
- //
- //
- // [self.view layoutIfNeeded];
- //}
- @end
|