// // DocumentViewController.m // AntsContract // // Created by Ray on 12/16/16. // Copyright © 2016 United Software Applications, Inc. All rights reserved. // #import "PageViewController.h" #import "config.h" #import "const.h" #import "SignatureListViewController.h" #import "SignatureViewController.h" #import "PDFUtils.h" #import "ImageUtils.h" #import "TextUtils.h" #import "CheckSelectorViewController.h" #import "DatePickerViewController.h" //#import "TouchImageView.h" @interface PageViewController () @end @implementation PageViewController - (void)viewDidLoad { [super viewDidLoad]; // self.pageIndex=1; // self.pdfPageView.pageIndex=self.pageIndex; self.pdfPageView.pageRef= self.pageRef; [self initControl]; // UIPinchGestureRecognizer *pinchGestureRecognizer = [[UIPinchGestureRecognizer alloc] // initWithTarget:self // action:@selector(handlePinch:)]; // // [self.view addGestureRecognizer:pinchGestureRecognizer]; // Do any additional setup after loading the view. } -(void) dealloc { // CFBridgingRelease(self.pageRef); } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } //- (void) handlePinch:(UIPinchGestureRecognizer*) recognizer //{ //// recognizer.view.transform = CGAffineTransformScale(recognizer.view.transform, recognizer.scale, recognizer.scale); //// recognizer.scale = 1; // // CGSize contentsize =self.pdfScrollView.contentSize; // // self.pdfScrollView.contentSize = CGSizeMake(contentsize.width*recognizer.scale, contentsize.height*recognizer.scale); //} -(void) initControl { int count = [self.controlTemplate[@"count"] intValue]; for(int i=0;i0) // marker_bg = [UIColor clearColor]; // else marker_bg=UIColorFromRGB(CK_BG); for(int i=0;i=3) { NSMutableDictionary* action = item[2]; NSArray* disable_arr = action[@"disable"] ; for(int d = 0 ; d 0 && [decimalString characterAtIndex:0] == '1'; if (length == 0 ) { textView.text = decimalString; return NO; } if((length >= 10 && !hasLeadingOne) ) { if(length>15) return NO; // newString=[[newString stringByReplacingOccurrencesOfString:@"-" withString:@""] mutableCopy]; // [newString insertString:@"-" atIndex:14]; // textView.text = newString; // return NO; } if((length >= 11)) { if(length>16) return NO; // newString=[[newString stringByReplacingOccurrencesOfString:@"-" withString:@""] mutableCopy]; // [newString insertString:@"-" atIndex:16]; // textView.text = newString; // return NO; } NSUInteger index = 0; NSMutableString *formattedString = [NSMutableString string]; if (hasLeadingOne) { [formattedString appendString:@"1 "]; index += 1; } if (length - index > 3) { NSString *areaCode = [decimalString substringWithRange:NSMakeRange(index, 3)]; [formattedString appendFormat:@"(%@) ",areaCode]; index += 3; } if (length - index > 3) { NSString *prefix = [decimalString substringWithRange:NSMakeRange(index, 3)]; [formattedString appendFormat:@"%@ ",prefix]; index += 3; } if (length - index > 4) { NSString *prefix = [decimalString substringWithRange:NSMakeRange(index, 4)]; [formattedString appendFormat:@"%@-",prefix]; index += 4; } NSString *remainder = [decimalString substringFromIndex:index]; [formattedString appendString:remainder]; textView.text = formattedString; return NO; } else { NSString* oldtext =textView.text; if(oldtext==nil) oldtext=@""; bool canChange=true; int max_line = [self.controlTemplate [[NSString stringWithFormat:@"control_%ld",index] ][@"lines"] intValue]; if(max_line==0)//默认只能有一行 max_line=1; long linecount=[TextUtils countOccurencesOfString:oldtext find:@"\n"]; if(max_line!=-1) //maxline -1表示不限制行数。 { if(linecount<=max_line-1&& [text isEqualToString:@"\n"]) { canChange = false; } } int lenth = [self.controlTemplate [[NSString stringWithFormat:@"control_%ld",index] ][@"length"] intValue]; if(lenth==0) return canChange; else { return canChange&& (lenth>textView.text.length ||[text isEqualToString:@""]); } } } - (void)textViewDidEndEditing:(UITextView *)textView { long index = textView.tag - CONTROL_BASE; //处理 prefix 和 浮点格式化 NSString* prefix_str= self.controlTemplate [[NSString stringWithFormat:@"control_%ld",index] ][@"prefix_str"]; if(prefix_str.length==0) prefix_str = @""; NSString* text = [textView.text stringByReplacingOccurrencesOfString:prefix_str withString:@""]; NSString* value_type= self.controlTemplate [[NSString stringWithFormat:@"control_%ld",index] ][@"value_type"]; if([value_type isEqualToString:@"float"]) text=[NSString stringWithFormat:@"%.2f",[text doubleValue] ]; text =[NSString stringWithFormat:@"%@%@",prefix_str,text] ; textView.text = text; if(text==nil) text=@""; self.controlTemplate [[NSString stringWithFormat:@"control_%ld",index] ][@"value"] = text; NSDictionary* action = self.controlTemplate [[NSString stringWithFormat:@"control_%ld",index] ][@"action"]; NSArray* keys=[action allKeys]; for(int k=0;k 指向item // // [popover presentPopoverFromRect:self.view.frame inView:self.view permittedArrowDirections:0 animated:YES]; // // [popover presentPopoverFromBarButtonItem:item permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; // //// self.popover = popover; // popover pop // // [self performSegueWithIdentifier:@"selector_popover" sender:self]; } // __block int tag = touchImageView.tag; // UIViewController* vc=[RAUtils getViewController :touchImageView]; // // if(self.editable==true) // { // // // ImageUploadViewController * uploadvc =[ vc.storyboard instantiateViewControllerWithIdentifier:@"ImageUploadViewController"]; // // // UIImage* img =[self.buttonImg backgroundImageForState:UIControlStateNormal];; // // if(self.img_validate) // uploadvc.img= touchImageView.image; // // uploadvc.returnValue = ^(NSString* url_down,NSString* url_up,UIImage* img) // { // // self.imgs[tag] = url_up; // // NSString* newurl=[RAUtils arr2string:self.imgs separator:@"," trim:false]; // // touchImageView.image=img; // // if(self.imgChanged) // self.imgChanged(url_down,newurl,tag,url_up); // // }; // // [vc.navigationController pushViewController:uploadvc animated:false]; // } // else // { // if(touchImageView.image==nil) // return ; // ImageViewController * imagevc =[ vc.storyboard instantiateViewControllerWithIdentifier:@"ImageViewController"]; // // // UIImage* img=touchImageView.image; // // if(self.img_validate) // imagevc.image = img;//.imageView.image = [self.buttonImg backgroundImageForState:UIControlStateNormal]; // // // uploadvc.returnValue = ^(NSString* url_down,NSString* url_up,UIImage* img) // // { // // // // [self.buttonImg setBackgroundImage:img forState:UIControlStateNormal]; // // // // if(self.imgChanged) // // self.imgChanged(url_down,url_up); // // // // }; // // [vc.navigationController pushViewController:imagevc animated:false]; // } // // bundleVC.content_data = self.bundle_item; // } @end