diff --git a/EUExControl/EUExControl.xcodeproj/project.pbxproj b/EUExControl/EUExControl.xcodeproj/project.pbxproj index 9cfbc81..c1598d3 100644 --- a/EUExControl/EUExControl.xcodeproj/project.pbxproj +++ b/EUExControl/EUExControl.xcodeproj/project.pbxproj @@ -10,6 +10,7 @@ 3C1C09AC1BE060A200571E72 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 3C1C09AE1BE060A200571E72 /* Localizable.strings */; }; 3CD39C841A78848B00F5BB9D /* CDatePickerViewEx.m in Sources */ = {isa = PBXBuildFile; fileRef = 3CD39C811A78848B00F5BB9D /* CDatePickerViewEx.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; 3CD39C851A78848B00F5BB9D /* MonthPicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 3CD39C831A78848B00F5BB9D /* MonthPicker.m */; }; + 4287467D1C294C9400219CDE /* Public_HIST.m in Sources */ = {isa = PBXBuildFile; fileRef = 4287467C1C294C9400219CDE /* Public_HIST.m */; }; 5A38ABCF1889391A00E3CB77 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5A38ABCE1889391A00E3CB77 /* Foundation.framework */; }; 5A60A96318AB63F800C727A6 /* DatePicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 5A60A95218AB63F800C727A6 /* DatePicker.m */; }; 5A60A96418AB63F800C727A6 /* HeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 5A60A95418AB63F800C727A6 /* HeaderView.m */; }; @@ -37,6 +38,8 @@ 3CD39C811A78848B00F5BB9D /* CDatePickerViewEx.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDatePickerViewEx.m; sourceTree = ""; }; 3CD39C821A78848B00F5BB9D /* MonthPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MonthPicker.h; sourceTree = ""; }; 3CD39C831A78848B00F5BB9D /* MonthPicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MonthPicker.m; sourceTree = ""; }; + 4287467B1C294C9400219CDE /* Public_HIST.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Public_HIST.h; sourceTree = ""; }; + 4287467C1C294C9400219CDE /* Public_HIST.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Public_HIST.m; sourceTree = ""; }; 5A38ABCB1889391A00E3CB77 /* libuexControl.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libuexControl.a; sourceTree = BUILT_PRODUCTS_DIR; }; 5A38ABCE1889391A00E3CB77 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 5A38ABD21889391A00E3CB77 /* EUExControl-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "EUExControl-Prefix.pch"; sourceTree = ""; }; @@ -169,6 +172,8 @@ 5A60A95418AB63F800C727A6 /* HeaderView.m */, 5A60A95518AB63F800C727A6 /* InputDialog.h */, 5A60A95618AB63F800C727A6 /* InputDialog.m */, + 4287467B1C294C9400219CDE /* Public_HIST.h */, + 4287467C1C294C9400219CDE /* Public_HIST.m */, 5A60A95718AB63F800C727A6 /* JSON */, 5A60A95F18AB63F800C727A6 /* PLGrowingTextView.h */, 5A60A96018AB63F800C727A6 /* PLGrowingTextView.m */, @@ -290,6 +295,7 @@ 5A60A96918AB63FE00C727A6 /* EUExControl.m in Sources */, 5A60A96518AB63F800C727A6 /* InputDialog.m in Sources */, 3CD39C851A78848B00F5BB9D /* MonthPicker.m in Sources */, + 4287467D1C294C9400219CDE /* Public_HIST.m in Sources */, 5A60A96718AB63F800C727A6 /* PLTextViewInternal.m in Sources */, 3CD39C841A78848B00F5BB9D /* CDatePickerViewEx.m in Sources */, 5A60A96618AB63F800C727A6 /* PLGrowingTextView.m in Sources */, diff --git a/EUExControl/EUExControl/EUExControl.h b/EUExControl/EUExControl/EUExControl.h index 0cb3ef6..02bf5a2 100755 --- a/EUExControl/EUExControl/EUExControl.h +++ b/EUExControl/EUExControl/EUExControl.h @@ -17,6 +17,7 @@ #define UEX_JKHOUR @"hour" #define UEX_JKMUNUTE @"minute" #define UEX_JKSECOND @"second" +#define UEX_JKWEEK @"week" @interface EUExControl : EUExBase { @@ -32,6 +33,9 @@ @property (nonatomic, retain)MonthPicker *monthObj; @property (nonatomic, retain) InputDialog * inputObj; @property (nonatomic, assign) BOOL isDataPickerDidOpen; +@property(nonatomic,strong)NSString * diaLogColor; +@property(nonatomic,strong)NSString * dialogButBg; +@property(nonatomic,strong)NSString * dialogETBg; -(void)uexOpenDatePickerWithOpId:(int)inOpId dataType:(int)inDataType data:(NSString*)inData; diff --git a/EUExControl/EUExControl/EUExControl.m b/EUExControl/EUExControl/EUExControl.m index 44c6527..d35a0da 100755 --- a/EUExControl/EUExControl/EUExControl.m +++ b/EUExControl/EUExControl/EUExControl.m @@ -14,6 +14,9 @@ @implementation EUExControl @synthesize dateObj; @synthesize monthObj; @synthesize inputObj; +@synthesize diaLogColor; +@synthesize dialogButBg; +@synthesize dialogETBg; -(id)initWithBrwView:(EBrowserView *) eInBrwView { if (self = [super initWithBrwView:eInBrwView]) { @@ -22,79 +25,28 @@ -(id)initWithBrwView:(EBrowserView *) eInBrwView { return self; } -- (UIColor *)stringToColor:(NSString *)aString{ - if ([aString isKindOfClass:[NSString class]] && aString.length > 0) { - UIColor *color = [EUtility ColorFromString:aString]; - return color; - }else{ - return nil; - } -} - --(void)setDatePickerConfirmBtnColor:(NSMutableArray *)inArguments{ - - if ([inArguments count] <= 0) { - - return; - } - - NSString * jsonStr = [inArguments objectAtIndex:0]; - NSMutableDictionary * jsDic = [jsonStr JSONValue]; - - NSString * titleColor = [jsDic objectForKey:@"leftBtnTitleColor"]; - if ([titleColor isKindOfClass:[NSString class]] && [titleColor length]>0) { - self.dateObj.toolView.canLabel.textColor = [self stringToColor:titleColor]; - } - - titleColor = [jsDic objectForKey:@"rightBtnTitleColor"]; - if ([titleColor isKindOfClass:[NSString class]] && [titleColor length]>0) { - self.dateObj.toolView.conLabel.textColor = [self stringToColor:titleColor]; - } -} - --(void)setDatePickerWithoutDayConfirmBtnColor:(NSMutableArray *)inArguments{ - - if ([inArguments count] <= 0) { - - return; - } - - NSString * jsonStr = [inArguments objectAtIndex:0]; - NSMutableDictionary * jsDic = [jsonStr JSONValue]; - - - NSString * titleColor = [jsDic objectForKey:@"leftBtnTitleColor"]; - if ([titleColor isKindOfClass:[NSString class]] && [titleColor length]>0) { - self.monthObj.toolView.canLabel.textColor = [self stringToColor:titleColor]; - } - - titleColor = [jsDic objectForKey:@"rightBtnTitleColor"]; - if ([titleColor isKindOfClass:[NSString class]] && [titleColor length]>0) { - self.monthObj.toolView.conLabel.textColor = [self stringToColor:titleColor]; - } -} - - -(void)clean{ if (dateObj) { - [[NSNotificationCenter defaultCenter] removeObserver:dateObj]; - [dateObj release]; - dateObj = nil; + self.dateObj = nil; } if(monthObj){ - [[NSNotificationCenter defaultCenter] removeObserver:monthObj]; - [monthObj release]; - monthObj = nil; + self.monthObj = nil; } - if (inputObj) { - [[NSNotificationCenter defaultCenter] removeObserver:inputObj]; - [inputObj release]; - inputObj = nil; + if (inputObj) { + self.inputObj = nil; } } -(void)dealloc{ - [self clean]; + if (dateObj) { + self.dateObj = nil; + } + if(monthObj){ + self.monthObj = nil; + } + if (inputObj) { + self.inputObj = nil; + } [super dealloc]; } @@ -106,6 +58,19 @@ -(void)openInputDialog:(NSMutableArray *)inArguments{ NSString * inHint = [inArguments objectAtIndex:1]; NSString * btnTitle = [inArguments objectAtIndex:2]; + + NSInteger a = inArguments.count; + if (inArguments.count==4) + { + NSString * bgParmString = [inArguments objectAtIndex:3]; + NSDictionary * dict = [bgParmString JSONValue]; + NSLog(@"%@",dict); + diaLogColor = [dict objectForKey:@"dialogBg"]; + dialogButBg = [dict objectForKey:@"dialogButBg"]; + dialogETBg = [dict objectForKey:@"dialogETBg"]; + } + + [inputObj release]; inputObj = nil; @@ -113,15 +78,26 @@ -(void)openInputDialog:(NSMutableArray *)inArguments{ float heightOfInputObj = 40; UIInterfaceOrientation cOrientation = [UIApplication sharedApplication].statusBarOrientation; if ((cOrientation == UIInterfaceOrientationLandscapeLeft) || (cOrientation == UIInterfaceOrientationLandscapeRight)) { - frameOfInputObj = CGRectMake(0, [EUtility screenWidth] - heightOfInputObj, [EUtility screenHeight], heightOfInputObj); + int width = [EUtility screenWidth]; + int height =[EUtility screenHeight]; + + int realwidth = MAX(width, height); + int realheight = MIN(width, height); + frameOfInputObj = CGRectMake(0, 0, realwidth, heightOfInputObj); } else { frameOfInputObj = CGRectMake(0, [EUtility screenHeight] - heightOfInputObj, [EUtility screenWidth], heightOfInputObj); } inputObj = [[InputDialog alloc] initWithFrame:frameOfInputObj]; - [inputObj openInputWithText:inHint btnText:btnTitle KeyBoardType:inType]; + inputObj.backgroundColor = [UIColor clearColor]; +// [inputObj openInputWithText:inHint btnText:btnTitle KeyBoardType:inType]; + NSString *path = [EUtility getAbsPath:self.meBrwView path:dialogETBg]; + NSString * btgPath = [EUtility getAbsPath:self.meBrwView path:dialogButBg]; + + [inputObj openInputWithText:inHint btnText:(btnTitle) KeyBoardType:inType dialogBg:diaLogColor dialogButBg:btgPath dialogETBg:path count:a]; [inputObj setDelegate:self]; + NSLog(@"------->>>%@",NSStringFromCGRect(inputObj.frame)); [EUtility brwView:meBrwView addSubview:inputObj]; - [EUtility brwView:meBrwView forbidRotate:YES]; + //[EUtility brwView:meBrwView forbidRotate:YES]; inputHasDisplay = YES; } @@ -167,6 +143,8 @@ -(void)openDatePicker:(NSMutableArray *)inArguments{ inDate = [NSDate date]; } [dateObj showDatePickerWithType:0 date:inDate]; + + } @@ -186,10 +164,13 @@ -(void)openDatePickerWithoutDay:(NSMutableArray *)inArguments{ if ([inYear isEqualToString:@""]||[inMonth isEqualToString:@""]) { inDate = [NSDate date]; }else { + // NSLog(@"[control opendatePicker"); NSString *dateStr = [NSString stringWithFormat:@"%@-%@",inYear,inMonth]; + // NSLog(@"datestr = %@",dateStr); NSDateFormatter *df = [[NSDateFormatter alloc] init]; [df setDateFormat:@"yyyy-MM"]; inDate = [df dateFromString:dateStr]; + // NSLog(@"inldate = %@",inDate); [df release]; } if (inDate == nil) { @@ -245,6 +226,7 @@ -(void)uexOpenDatePickerWithOpId:(int)inOpId dataType:(int)inDataType data:(NSSt -(void)uexOpenMonthPickerWithOpId:(int)inOpId dataType:(int)inDataType data:(NSString*)inData{ inData =[inData stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; [self jsSuccessWithName:@"uexControl.cbOpenDatePickerWithoutDay" opId:inOpId dataType:inDataType strData:inData]; + NSLog(@"%@",inData); } -(void)uexOpenTimerPickerWithOpId:(int)inOpId dataType:(int)inDataType data:(NSString*)inData{ inData =[inData stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; diff --git a/EUExControl/EUExControl/sourceCode/DatePicker.m b/EUExControl/EUExControl/sourceCode/DatePicker.m index 8e17b3e..0df1f80 100755 --- a/EUExControl/EUExControl/sourceCode/DatePicker.m +++ b/EUExControl/EUExControl/sourceCode/DatePicker.m @@ -16,6 +16,7 @@ #define HEAD_HEIGHT 40 #define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width) #define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height) +#define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) @implementation DatePicker @synthesize pickerType; @@ -27,22 +28,15 @@ @implementation DatePicker @synthesize popController; -(id)initWithEuex:(EUExControl *)euexObj_{ - - if (self = [super init]) { - - self.euexObj = euexObj_; - - } - + self.euexObj = euexObj_; return self; - } -(void)setResultFormat:(NSDate *)inDate{ NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSInteger unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSWeekdayCalendarUnit | - NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit; + NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit|NSCalendarUnitWeekday; NSDateComponents *comps = [calendar components:unitFlags fromDate:inDate]; @@ -52,6 +46,7 @@ -(void)setResultFormat:(NSDate *)inDate{ int hour = [comps hour]; int min = [comps minute]; int sec = [comps second]; + int week = [comps week]; [calendar release]; [selectValue setObject:[NSNumber numberWithInt:year] forKey:UEX_JKYEAR]; @@ -60,50 +55,74 @@ -(void)setResultFormat:(NSDate *)inDate{ [selectValue setObject:[NSNumber numberWithInt:hour] forKey:UEX_JKHOUR]; [selectValue setObject:[NSNumber numberWithInt:min] forKey:UEX_JKMUNUTE]; [selectValue setObject:[NSNumber numberWithInt:sec] forKey:UEX_JKSECOND]; + [selectValue setObject:[NSNumber numberWithInt:week] forKey:UEX_JKWEEK]; } - (void)changeDate:(id)sender{ NSDate * checkDate = pickerView.date; [self setResultFormat:checkDate]; } - +//------------------>>>>>>>>>>>>>>>监听翻转<<<<<<<<<<<<<<<<<<----------------------------; -(void)doRotate{ - - - - if (![mainView isKindOfClass:[UIView class]] || ![toolView isKindOfClass:[HeaderView class]] || ![pickerView isKindOfClass:[UIDatePicker class]]) { - return; - } - - UIInterfaceOrientation deviceOrientation = [[UIApplication sharedApplication] statusBarOrientation]; - if ([EUtility isIpad]) { - [mainView setFrame:CGRectMake(0, [EUtility screenHeight] - MAIN_HEIGHT, 320*APP_DEVICERATIO, MAIN_HEIGHT)]; - [toolView setFrame:CGRectMake(0, 0, 320*APP_DEVICERATIO, 40)]; - [toolView.lay setFrame:CGRectMake(0, 0, 320*APP_DEVICERATIO, 40)]; - [toolView.cancle setFrame:CGRectMake(5, 5, 41, 30)]; - [toolView.confirm setFrame:CGRectMake(320*APP_DEVICERATIO - 46, 5, 41, 30)]; - [pickerView setFrame:CGRectMake(0, 40, 320*APP_DEVICERATIO, MAIN_HEIGHT-40)]; - return; - } - - - - - if (deviceOrientation == UIInterfaceOrientationPortrait||deviceOrientation == UIInterfaceOrientationPortraitUpsideDown) { +// if ([EUtility isIpad]) { +// return; +// }{ + if(isPad) + { + UIInterfaceOrientation deviceOrientation = [[UIApplication sharedApplication] statusBarOrientation]; + if (deviceOrientation == UIInterfaceOrientationPortrait||deviceOrientation == UIInterfaceOrientationPortraitUpsideDown) { [mainView setFrame:CGRectMake(0, [EUtility screenHeight] - MAIN_HEIGHT, 320*APP_DEVICERATIO, MAIN_HEIGHT)]; [toolView setFrame:CGRectMake(0, 0, 320*APP_DEVICERATIO, 40)]; [toolView.lay setFrame:CGRectMake(0, 0, 320*APP_DEVICERATIO, 40)]; [toolView.cancle setFrame:CGRectMake(5, 5, 41, 30)]; [toolView.confirm setFrame:CGRectMake(320*APP_DEVICERATIO - 46, 5, 41, 30)]; [pickerView setFrame:CGRectMake(0, 40, 320*APP_DEVICERATIO, MAIN_HEIGHT-40)]; - }else if (deviceOrientation == UIInterfaceOrientationLandscapeLeft||deviceOrientation == UIInterfaceOrientationLandscapeRight){ - [mainView setFrame:CGRectMake(0, 300 - MAIN_HEIGHT, [EUtility screenHeight], MAIN_HEIGHT)]; - [toolView setFrame:CGRectMake(0, 0, [EUtility screenHeight], 40)]; - [toolView.lay setFrame:CGRectMake(0, 0, [EUtility screenHeight], 40)]; - [toolView.confirm setFrame:CGRectMake([EUtility screenHeight] - 46, 5, 41, 30)]; + + + + } + else if (deviceOrientation == UIInterfaceOrientationLandscapeLeft||deviceOrientation == UIInterfaceOrientationLandscapeRight) + { + int width = [EUtility screenWidth]; + int height =[EUtility screenHeight]; + + int realwidth = MAX(width, height); + int realheight = MIN(width, height); + + + [mainView setFrame:CGRectMake(0, realheight - MAIN_HEIGHT, realwidth, MAIN_HEIGHT)]; + [toolView setFrame:CGRectMake(0, 0, realwidth, 40)]; + [toolView.lay setFrame:CGRectMake(0, 0, realwidth, 40)]; + [toolView.confirm setFrame:CGRectMake(realwidth - 46, 5, 41, 30)]; [toolView.cancle setFrame:CGRectMake(5, 5, 41, 30)]; - [pickerView setFrame:CGRectMake(0, 40, [EUtility screenHeight], MAIN_HEIGHT - 40)]; + [pickerView setFrame:CGRectMake(0, 40, realwidth, MAIN_HEIGHT - 40)]; + } + + } + //手机版; + else + { + UIInterfaceOrientation deviceOrientation = [[UIApplication sharedApplication] statusBarOrientation]; + if (deviceOrientation == UIInterfaceOrientationPortrait||deviceOrientation == UIInterfaceOrientationPortraitUpsideDown) { + [mainView setFrame:CGRectMake(0, [EUtility screenHeight] - MAIN_HEIGHT, 320*APP_DEVICERATIO, MAIN_HEIGHT)]; + [toolView setFrame:CGRectMake(0, 0, [EUtility screenWidth], 40)]; + [toolView.lay setFrame:CGRectMake(0, 0, [EUtility screenWidth], 40)]; + [toolView.cancle setFrame:CGRectMake(5, 5, 41, 30)]; + [toolView.confirm setFrame:CGRectMake([EUtility screenWidth] - 46, 5, 41, 30)]; + [pickerView setFrame:CGRectMake(0, 40, [EUtility screenWidth], MAIN_HEIGHT-40)]; + }else if (deviceOrientation == UIInterfaceOrientationLandscapeLeft||deviceOrientation == UIInterfaceOrientationLandscapeRight){ + + [mainView setFrame:CGRectMake(0,[UIScreen mainScreen].bounds.size.height-MAIN_HEIGHT,[UIScreen mainScreen].bounds.size.width, MAIN_HEIGHT)]; + [toolView setFrame:CGRectMake(0, 0, [EUtility screenWidth], 40)]; + [toolView.lay setFrame:CGRectMake(0, 0, [EUtility screenWidth], 40)]; + [toolView.confirm setFrame:CGRectMake([EUtility screenWidth] - 46, 5, 41, 30)]; + [toolView.cancle setFrame:CGRectMake(5, 5, 41, 30)]; + [pickerView setFrame:CGRectMake(0, 40,[ UIScreen mainScreen].bounds.size.width, MAIN_HEIGHT - 40)]; + + } + + } } -(void)showDatePickerWithType:(int)type date:(NSDate *)inDate{ @@ -118,56 +137,136 @@ -(void)showDatePickerWithType:(int)type date:(NSDate *)inDate{ [self setResultFormat:inDate]; - UIInterfaceOrientation deviceOrientation = [[UIApplication sharedApplication] statusBarOrientation]; - if ([EUtility isIpad] || deviceOrientation == UIInterfaceOrientationPortrait || deviceOrientation == UIInterfaceOrientationPortraitUpsideDown) { - self.mainView = [[[UIView alloc] initWithFrame:CGRectMake(0, [EUtility screenHeight], 320*APP_DEVICERATIO, MAIN_HEIGHT)] autorelease]; - self.toolView = [[[HeaderView alloc] initWithFrame:CGRectMake(0, 0, 320*APP_DEVICERATIO, 40)] autorelease]; - self.pickerView = [[[UIDatePicker alloc] init] autorelease]; - [pickerView setFrame:CGRectMake(0, 40, 320*APP_DEVICERATIO, MAIN_HEIGHT-40)]; - }else { - self.mainView = [[[UIView alloc] initWithFrame:CGRectMake(0, 300-MAIN_HEIGHT, [EUtility screenHeight], MAIN_HEIGHT)] autorelease]; - self.toolView = [[[HeaderView alloc] initWithFrame:CGRectMake(0, 0,[EUtility screenHeight], 40)] autorelease]; - self.pickerView = [[[UIDatePicker alloc] init] autorelease]; - [pickerView setFrame:CGRectMake(0, 40, [EUtility screenHeight], MAIN_HEIGHT-40)]; - } - toolView.delegate = self; - if (type == 0) { - pickerView.datePickerMode = UIDatePickerModeDate; - }else { - pickerView.datePickerMode = UIDatePickerModeTime; - } - - pickerView.date = inDate; - [pickerView addTarget:self action:@selector(changeDate:) forControlEvents:UIControlEventValueChanged]; - [mainView addSubview:toolView]; - [mainView setBackgroundColor:[UIColor whiteColor]]; - [mainView addSubview:pickerView]; - if (![EUtility isIpad] || SCREEN_WIDTH == 320*APP_DEVICERATIO) { - [EUtility brwView:euexObj.meBrwView addSubview:mainView]; - if (euexObj.meBrwView) { - if ([EUtility isIpad] || deviceOrientation == UIInterfaceOrientationPortrait || deviceOrientation == UIInterfaceOrientationPortraitUpsideDown) { - [UIView animateWithDuration:0.3 animations:^{ - [mainView setFrame:CGRectMake(0, [EUtility screenHeight]-MAIN_HEIGHT, 320*APP_DEVICERATIO, MAIN_HEIGHT)]; - }]; + if (isPad) + { + + UIInterfaceOrientation deviceOrientation = [[UIApplication sharedApplication] statusBarOrientation]; + if (deviceOrientation == UIInterfaceOrientationPortrait || deviceOrientation == UIInterfaceOrientationPortraitUpsideDown) { + + self.mainView = [[[UIView alloc] initWithFrame:CGRectMake(0, [EUtility screenHeight], 320*APP_DEVICERATIO, MAIN_HEIGHT)] autorelease]; + self.toolView = [[[HeaderView alloc] initWithFrame:CGRectMake(0, 0, 320*APP_DEVICERATIO, 40)] autorelease]; + self.pickerView = [[[UIDatePicker alloc] init] autorelease]; + [pickerView setFrame:CGRectMake(0, 40, 320*APP_DEVICERATIO, MAIN_HEIGHT-40)]; + + + }else { + + int width = [EUtility screenWidth]; + int height =[EUtility screenHeight]; + + int realwidth = MAX(width, height); + int realheight = MIN(width, height); + + self.mainView = [[[UIView alloc] initWithFrame:CGRectMake(0, realheight-MAIN_HEIGHT, realheight, MAIN_HEIGHT)] autorelease]; + self.toolView = [[[HeaderView alloc] initWithFrame:CGRectMake(0, 0, realwidth, 40)] autorelease]; + self.pickerView = [[[UIDatePicker alloc] init] autorelease]; + [pickerView setFrame:CGRectMake(0, 40,realheight, MAIN_HEIGHT-40)]; + NSLog(@"%@",NSStringFromCGRect(pickerView.frame)); + + } + toolView.delegate = self; + if (type == 0) { + pickerView.datePickerMode = UIDatePickerModeDate; + }else { + pickerView.datePickerMode = UIDatePickerModeTime; + } + + pickerView.date = inDate; + [pickerView addTarget:self action:@selector(changeDate:) forControlEvents:UIControlEventValueChanged]; + [mainView addSubview:toolView]; + [mainView setBackgroundColor:[UIColor whiteColor]]; + [mainView addSubview:pickerView]; + if (![EUtility isIpad] || SCREEN_WIDTH == 320*APP_DEVICERATIO) { + [EUtility brwView:euexObj.meBrwView addSubview:mainView]; + if (euexObj.meBrwView) { + if (![EUtility isIpad] || deviceOrientation == UIInterfaceOrientationPortrait || deviceOrientation == UIInterfaceOrientationPortraitUpsideDown) { + [UIView animateWithDuration:0.3 animations:^{ + [mainView setFrame:CGRectMake(0, [EUtility screenHeight]-MAIN_HEIGHT, 320*APP_DEVICERATIO, MAIN_HEIGHT)]; + }]; + } + [(UIView*)euexObj.meBrwView setUserInteractionEnabled:NO]; } - [(UIView*)euexObj.meBrwView setUserInteractionEnabled:NO]; + }else { + UIViewController *controller = [[UIViewController alloc] init]; + controller.view = mainView; + UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:controller]; + [controller release]; + self.popController = popover; + [popover release]; + + [popController setPopoverContentSize:CGSizeMake(320*APP_DEVICERATIO, MAIN_HEIGHT)]; + [popController setDelegate:self]; + //让pop窗口的位置在中间 + int x = SCREEN_WIDTH/2; + int y = (SCREEN_HEIGHT-20)/2; + [EUtility brwView:euexObj.meBrwView presentPopover:popController FromRect:CGRectMake(x, y, 10, 10) permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; + } + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doRotate) name:UIDeviceOrientationDidChangeNotification object:nil]; + + } + + //手机版; + else{ + + UIInterfaceOrientation deviceOrientation = [[UIApplication sharedApplication] statusBarOrientation]; + if (deviceOrientation == UIInterfaceOrientationPortrait || deviceOrientation == UIInterfaceOrientationPortraitUpsideDown) { + self.mainView = [[[UIView alloc] initWithFrame:CGRectMake(0, [EUtility screenHeight], 320*APP_DEVICERATIO, MAIN_HEIGHT)] autorelease]; + self.toolView = [[[HeaderView alloc] initWithFrame:CGRectMake(0, 0, 320*APP_DEVICERATIO, 40)] autorelease]; + self.pickerView = [[[UIDatePicker alloc] init] autorelease]; + + [pickerView setFrame:CGRectMake(0, 40, 320*APP_DEVICERATIO, MAIN_HEIGHT-40)]; + }else { + self.mainView = [[[UIView alloc] initWithFrame:CGRectMake(0, [EUtility screenWidth]-MAIN_HEIGHT, [UIScreen mainScreen].bounds.size.height, MAIN_HEIGHT)] autorelease]; + self.toolView = [[[HeaderView alloc] initWithFrame:CGRectMake(0, 0, [EUtility screenWidth], 40)] autorelease]; + + self.pickerView = [[[UIDatePicker alloc] init] autorelease]; + + [pickerView setFrame:CGRectMake(0, 40,[EUtility screenWidth], MAIN_HEIGHT-40)]; + NSLog(@"%@",NSStringFromCGRect(pickerView.frame)); + [self.toolView.confirm setFrame:CGRectMake([EUtility screenWidth] - 46, 5, 41, 30)]; + + } + + toolView.delegate = self; + if (type == 0) { + pickerView.datePickerMode = UIDatePickerModeDate; + }else { + pickerView.datePickerMode = UIDatePickerModeTime; } - }else { - UIViewController *controller = [[UIViewController alloc] init]; - controller.view = mainView; - UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:controller]; - [controller release]; - self.popController = popover; - [popover release]; - [popController setPopoverContentSize:CGSizeMake(320*APP_DEVICERATIO, MAIN_HEIGHT)]; - [popController setDelegate:self]; - //让pop窗口的位置在中间 - int x = SCREEN_WIDTH/2; - int y = (SCREEN_HEIGHT-20)/2; - [EUtility brwView:euexObj.meBrwView presentPopover:popController FromRect:CGRectMake(x, y, 10, 10) permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; - } - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doRotate) name:UIDeviceOrientationDidChangeNotification object:nil]; + pickerView.date = inDate; + [pickerView addTarget:self action:@selector(changeDate:) forControlEvents:UIControlEventValueChanged]; + [mainView addSubview:toolView]; + [mainView setBackgroundColor:[UIColor whiteColor]]; + [mainView addSubview:pickerView]; + if (![EUtility isIpad] || SCREEN_WIDTH == 320*APP_DEVICERATIO) { + [EUtility brwView:euexObj.meBrwView addSubview:mainView]; + if (euexObj.meBrwView) { + if (![EUtility isIpad] || deviceOrientation == UIInterfaceOrientationPortrait || deviceOrientation == UIInterfaceOrientationPortraitUpsideDown) { + [UIView animateWithDuration:0.3 animations:^{ + [mainView setFrame:CGRectMake(0, [EUtility screenHeight]-MAIN_HEIGHT, 320*APP_DEVICERATIO, MAIN_HEIGHT)]; + }]; + } + [(UIView*)euexObj.meBrwView setUserInteractionEnabled:NO]; + } + }else { + UIViewController *controller = [[UIViewController alloc] init]; + controller.view = mainView; + UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:controller]; + [controller release]; + self.popController = popover; + [popover release]; + + [popController setPopoverContentSize:CGSizeMake(320*APP_DEVICERATIO, MAIN_HEIGHT)]; + [popController setDelegate:self]; + //让pop窗口的位置在中间 + int x = SCREEN_WIDTH/2; + int y = (SCREEN_HEIGHT-20)/2; + [EUtility brwView:euexObj.meBrwView presentPopover:popController FromRect:CGRectMake(x, y, 10, 10) permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; + + } + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doRotate) name:UIDeviceOrientationDidChangeNotification object:nil]; + } } -(BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController{ @@ -232,25 +331,20 @@ - (void)confirm:(id)headerView{ -(void)dealloc{ [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil]; if (popController) { - [popController release]; - popController = nil; + self.popController = nil; } if (pickerView) { - [pickerView release]; - pickerView = nil; + self.pickerView = nil; } if (toolView) { - toolView.delegate = nil; - [toolView release]; - toolView = nil; + self.toolView.delegate = nil; + self.toolView = nil; } - if (mainView) { - [mainView release]; - mainView = nil; + if (mainView) { + self.mainView = nil; } - if (selectValue) { - [selectValue release]; - selectValue = nil; + if (selectValue) { + self.selectValue = nil; } [super dealloc]; } diff --git a/EUExControl/EUExControl/sourceCode/HeaderView.h b/EUExControl/EUExControl/sourceCode/HeaderView.h index 1e69541..e14e286 100755 --- a/EUExControl/EUExControl/sourceCode/HeaderView.h +++ b/EUExControl/EUExControl/sourceCode/HeaderView.h @@ -28,8 +28,4 @@ @property (nonatomic, retain) UIButton * cancle; @property (nonatomic, retain) UIButton * confirm; @property (nonatomic, assign) CAGradientLayer * lay; - -@property (nonatomic, retain) UILabel * canLabel; -@property (nonatomic, retain) UILabel *conLabel; - @end diff --git a/EUExControl/EUExControl/sourceCode/HeaderView.m b/EUExControl/EUExControl/sourceCode/HeaderView.m index dbef0f3..30d4a8d 100755 --- a/EUExControl/EUExControl/sourceCode/HeaderView.m +++ b/EUExControl/EUExControl/sourceCode/HeaderView.m @@ -8,7 +8,6 @@ #import "HeaderView.h" #import "EUtility.h" -#import "EUExControl.h" @implementation HeaderView @synthesize delegate,cancle,confirm,lay; @@ -41,38 +40,25 @@ - (id)initWithFrame:(CGRect)frame { [self setBackgroundColor:[UIColor whiteColor]]; } ////取消按钮 - UILabel * canLabel = [[UILabel alloc] initWithFrame:CGRectMake(7, 2.5, 50, 25)]; - - //默认设置“取消”,”确认”按钮颜色为"#007aff" - NSString *colorStr = @"#007aff"; - - canLabel.text = UEX_LOCALIZEDSTRING(@"取消"); + UILabel * canLabel = [[UILabel alloc] initWithFrame:CGRectMake(7, 2.5, 35, 25)]; + canLabel.text = @"取消"; canLabel.textColor = [UIColor blackColor]; - canLabel.font = [UIFont systemFontOfSize:12.0]; - - canLabel.textColor = [EUtility ColorFromString:colorStr]; - canLabel.font = [UIFont systemFontOfSize:16.0f]; - + canLabel.font = [UIFont systemFontOfSize:14.0]; [canLabel setBackgroundColor:[UIColor clearColor]]; - self.canLabel = canLabel; - cancle = [[UIButton alloc] initWithFrame:CGRectMake(5, 5, 55, 30)]; - //[cancle setImage:[UIImage imageNamed:@"uexControl/top_button.png"] forState:UIControlStateNormal]; + cancle = [[UIButton alloc] initWithFrame:CGRectMake(5, 5, 41, 30)]; + [cancle setImage:[UIImage imageNamed:@"uexControl/top_button.png"] forState:UIControlStateNormal]; [cancle addTarget:self action:@selector(cancleButtonClicked) forControlEvents:UIControlEventTouchUpInside]; [cancle addSubview:canLabel]; [canLabel release]; /////////确定按钮 - UILabel *conLabel = [[UILabel alloc] initWithFrame:CGRectMake(7, 2.5, 50, 25)]; - conLabel.text = UEX_LOCALIZEDSTRING(@"完成"); + UILabel *conLabel = [[UILabel alloc] initWithFrame:CGRectMake(7, 2.5, 35, 25)]; + conLabel.text = @"完成"; conLabel.textColor = [UIColor blackColor]; - conLabel.font = [UIFont systemFontOfSize:12.0]; - conLabel.textColor = [EUtility ColorFromString:colorStr]; - conLabel.font = [UIFont systemFontOfSize:16.0f]; - [conLabel setBackgroundColor:[UIColor clearColor]]; - self.conLabel = conLabel; - - confirm = [[UIButton alloc] initWithFrame:CGRectMake(frame.size.width-55, 5, 55, 30)]; - //[confirm setImage:[UIImage imageNamed:@"uexControl/top_button.png"] forState:UIControlStateNormal]; + conLabel.font = [UIFont systemFontOfSize:14.0]; + + confirm = [[UIButton alloc] initWithFrame:CGRectMake(self.frame.size.width-46, 5, 41, 30)]; + [confirm setImage:[UIImage imageNamed:@"uexControl/top_button.png"] forState:UIControlStateNormal]; [confirm addTarget:self action:@selector(confirmButtonClicked) forControlEvents:UIControlEventTouchUpInside]; [confirm addSubview:conLabel]; [conLabel release]; @@ -82,7 +68,6 @@ - (id)initWithFrame:(CGRect)frame { } return self; } - - (void)cancleButtonClicked { if(delegate != nil && [delegate respondsToSelector: @selector(cancled:)] == YES){ [delegate cancled:self]; @@ -91,11 +76,10 @@ - (void)cancleButtonClicked { - (void)confirmButtonClicked { if(delegate != nil && [delegate respondsToSelector: @selector(confirm:)] == YES){ - [delegate confirm:self]; + [delegate confirm:self]; } } - /* // Only override drawRect: if you perform custom drawing. // An empty implementation adversely affects performance during animation. @@ -108,8 +92,6 @@ - (void)dealloc { self.cancle = nil; self.confirm = nil; self.lay = nil; - self.canLabel = nil; - self.conLabel = nil; [super dealloc]; } diff --git a/EUExControl/EUExControl/sourceCode/InputDialog.h b/EUExControl/EUExControl/sourceCode/InputDialog.h index df7cee6..f85659e 100755 --- a/EUExControl/EUExControl/sourceCode/InputDialog.h +++ b/EUExControl/EUExControl/sourceCode/InputDialog.h @@ -27,7 +27,13 @@ typedef enum AppCanKeyBroardKeys { float mainWidth; float mainHeight; BOOL isLandspace; + UIImageView *entryImageView; } +@property(nonatomic,strong)NSMutableDictionary * Viewdic; +@property(nonatomic,strong)UIButton *doneBtn; +@property(nonatomic,strong) UIView * view; +@property(nonatomic,strong)UIImageView *entryImageView; +@property(nonatomic,strong)NSString * strings; @property(assign)id delegate; --(void)openInputWithText:(NSString*)placeholderText btnText:(NSString*)btnString KeyBoardType:(int)keyBoardType; +-(void)openInputWithText:(NSString*)placeholderText btnText:(NSString*)btnString KeyBoardType:(int)keyBoardType dialogBg:(NSString*)diaLogColor dialogButBg:(NSString*)dialogButBg dialogETBg:(NSString*)dialogETBg count:(NSInteger)counts; @end diff --git a/EUExControl/EUExControl/sourceCode/InputDialog.m b/EUExControl/EUExControl/sourceCode/InputDialog.m index 7226220..8a02edf 100755 --- a/EUExControl/EUExControl/sourceCode/InputDialog.m +++ b/EUExControl/EUExControl/sourceCode/InputDialog.m @@ -9,10 +9,15 @@ #import "InputDialog.h" #import "EUtility.h" #import +#import "Public_HIST.h" +#import "EUtility.h" @implementation InputDialog @synthesize delegate = _delegate; - +@synthesize strings; +@synthesize entryImageView; +@synthesize doneBtn; +@synthesize view; #define HEIGHT_STATUS 20 @@ -36,16 +41,52 @@ - (void) registerForKeyboardNotifications { selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; - - } -(void)removeKeyboardNotifucations { [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil]; } --(void)openInputWithText:(NSString*)placeholderText btnText:(NSString*)btnString KeyBoardType:(int)keyBoardType{ + + +////检测旋转; +-(void)doRotate{ +// if ([EUtility isIpad]) { +// return; +// } + UIInterfaceOrientation deviceOrientation = [[UIApplication sharedApplication] statusBarOrientation]; + if (deviceOrientation == UIInterfaceOrientationPortrait||deviceOrientation == UIInterfaceOrientationPortraitUpsideDown) + { + int width = [EUtility screenWidth]; + int height =[EUtility screenHeight]; + + int realwidth = MAX(width, height); + int realheight = MIN(width, height); + view = [[UIView alloc]initWithFrame:CGRectMake(0, 5, realheight, 60)]; + NSLog(@"选转之后:%@",NSStringFromCGRect(view.frame)); + textView = [[PLGrowingTextView alloc] initWithFrame:CGRectMake(11, 50, realheight - 80, 40)]; + doneBtn.frame = CGRectMake(self.frame.size.width - 62, 5,55 , 40); + + entryImageView.frame = CGRectMake(10, 10, realheight-82, 40); + + } + else if (deviceOrientation == UIInterfaceOrientationLandscapeLeft||deviceOrientation == UIInterfaceOrientationLandscapeRight) + { + int width = [EUtility screenWidth]; + int height =[EUtility screenHeight]; + int realwidth = MAX(width, height); + int realheight = MIN(width, height); + view = [[UIView alloc]initWithFrame:CGRectMake(0,0, realwidth, 40)]; + textView = [[PLGrowingTextView alloc] initWithFrame:CGRectMake(11, 13, realwidth - 80, 40)]; + doneBtn.frame = CGRectMake(realwidth - 62, 10,55 , 40); + NSLog(@"旋转后的位置:%@",NSStringFromCGRect(doneBtn.frame)); + entryImageView.frame = CGRectMake(10, 10, realwidth-82, 40); + } +} + +-(void)openInputWithText:(NSString*)placeholderText btnText:(NSString*)btnString KeyBoardType:(int)keyBoardType dialogBg:(NSString*)diaLogColor dialogButBg:(NSString*)dialogButBg dialogETBg:(NSString*)dialogETBg count:(NSInteger)counts { //键盘高度,iphone5以前是216,5以后对中英文做不同处理,中文键盘高252,英文键盘高216。ipad键盘,横屏264。shu屏是352 //注册通知 + [self registerForKeyboardNotifications]; UIInterfaceOrientation cOrientation = [UIApplication sharedApplication].statusBarOrientation; if (cOrientation == UIInterfaceOrientationLandscapeRight || cOrientation == UIInterfaceOrientationLandscapeLeft) { @@ -61,101 +102,243 @@ -(void)openInputWithText:(NSString*)placeholderText btnText:(NSString*)btnString if (![statusBarStyleIOS7 boolValue]) { mainHeight -= HEIGHT_STATUS; } - textView = [[PLGrowingTextView alloc] initWithFrame:CGRectMake(6, 3, mainWidth - 80, 40)]; - textView.contentInset = UIEdgeInsetsMake(0, 5, 0, 5); - - textView.minNumberOfLines = 1; - if (isLandspace) { - textView.maxNumberOfLines = 4; - } else { - textView.maxNumberOfLines = 6; - } - - switch (keyBoardType) { - case StandardKB: - break; - case NumberKB: - [textView.internalTextView setKeyboardType:UIKeyboardTypeNumberPad]; - break; - case EmailKB: - [textView.internalTextView setKeyboardType:UIKeyboardTypeEmailAddress]; - break; - case URLKB: - [textView.internalTextView setKeyboardType:UIKeyboardTypeURL]; - break; - case PassWordKB: - textView.internalTextView.secureTextEntry = YES; - break; - /*case 5: - [textView.internalTextView setKeyboardType:UIKeyboardTypeASCIICapable]; - break; - case 6: - [textView.internalTextView setKeyboardType:UIKeyboardTypeNumbersAndPunctuation]; - break; - case 7: - [textView.internalTextView setKeyboardType:UIKeyboardTypePhonePad]; - break; - case 8: - [textView.internalTextView setKeyboardType:UIKeyboardTypeNamePhonePad]; - break; - case 9: - [textView.internalTextView setKeyboardType:UIKeyboardTypeDecimalPad]; - break; */ - default: - break; - } - textView.returnKeyType = UIReturnKeyDone; //just as an example - textView.font = [UIFont systemFontOfSize:16.0f]; - textView.delegate = self; - textView.internalTextView.scrollIndicatorInsets = UIEdgeInsetsMake(5, 0, 5, 0); - textView.backgroundColor = [UIColor whiteColor]; - textView.text = placeholderText; - [textView becomeFirstResponder]; - - - UIImage * rawEntryBackground = [UIImage imageNamed:@"uexControl/plugin_control_input_field.png"]; - UIImage *entryBackground = [rawEntryBackground stretchableImageWithLeftCapWidth:13 topCapHeight:22]; - UIImageView *entryImageView = [[[UIImageView alloc] initWithImage:entryBackground] autorelease]; - entryImageView.frame = CGRectMake(5, 0, mainWidth-72, 40); - entryImageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; - - UIImage *rawBackground = [UIImage imageNamed:@"uexControl/plugin_control_input_entry_bg.png"]; - UIImage *background = [rawBackground stretchableImageWithLeftCapWidth:13 topCapHeight:22]; - UIImageView *imageView = [[[UIImageView alloc] initWithImage:background] autorelease]; - imageView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height); - imageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; - textView.autoresizingMask = UIViewAutoresizingFlexibleWidth; + // 旋转屏幕; - // view hierachy - [self addSubview:imageView]; - [self addSubview:textView]; - [self addSubview:entryImageView]; - UIImage *sendBtnBackground = [[UIImage imageNamed:@"uexControl/plugin_control_input_btn_bg.png"] stretchableImageWithLeftCapWidth:13 topCapHeight:0]; - UIImage *selectedSendBtnBackground = [[UIImage imageNamed:@"uexControl/plugin_control_input_btn_pressed.png"] stretchableImageWithLeftCapWidth:13 topCapHeight:0]; + UIInterfaceOrientation deviceOrientation = [[UIApplication sharedApplication] statusBarOrientation]; + if (deviceOrientation == UIInterfaceOrientationPortrait || deviceOrientation == UIInterfaceOrientationPortraitUpsideDown) { - UIButton *doneBtn = [UIButton buttonWithType:UIButtonTypeCustom]; - doneBtn.frame = CGRectMake(self.frame.size.width - 69, 8,63 , 27); - doneBtn.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin; - [doneBtn setTitleShadowColor:[UIColor colorWithWhite:0 alpha:0.4] forState:UIControlStateNormal]; - doneBtn.titleLabel.shadowOffset = CGSizeMake (0.0, -1.0); - doneBtn.titleLabel.font = [UIFont boldSystemFontOfSize:18.0f]; - if ([btnString length]==0) { - [doneBtn setTitle:UEX_LOCALIZEDSTRING(@"确定") forState:UIControlStateNormal]; + view = [[UIView alloc]initWithFrame:CGRectMake(0, -10, mainWidth, 60)]; + view.backgroundColor = [Public_HIST strToColor:diaLogColor]; + [self addSubview:view]; + + textView = [[PLGrowingTextView alloc] initWithFrame:CGRectMake(11, 2, mainWidth - 80, 40)]; + textView.contentInset = UIEdgeInsetsMake(0, 5, 0, 5); + textView.minNumberOfLines = 1; + if (isLandspace) { + textView.maxNumberOfLines = 4; + } else { + textView.maxNumberOfLines = 6; + } + + switch (keyBoardType) { + case StandardKB: + break; + case NumberKB: + [textView.internalTextView setKeyboardType:UIKeyboardTypeNumberPad]; + break; + case EmailKB: + [textView.internalTextView setKeyboardType:UIKeyboardTypeEmailAddress]; + break; + case URLKB: + [textView.internalTextView setKeyboardType:UIKeyboardTypeURL]; + break; + case PassWordKB: + textView.internalTextView.secureTextEntry = YES; + break; + /*case 5: + [textView.internalTextView setKeyboardType:UIKeyboardTypeASCIICapable]; + break; + case 6: + [textView.internalTextView setKeyboardType:UIKeyboardTypeNumbersAndPunctuation]; + break; + case 7: + [textView.internalTextView setKeyboardType:UIKeyboardTypePhonePad]; + break; + case 8: + [textView.internalTextView setKeyboardType:UIKeyboardTypeNamePhonePad]; + break; + case 9: + [textView.internalTextView setKeyboardType:UIKeyboardTypeDecimalPad]; + break; */ + default: + break; + } + + textView.returnKeyType = UIReturnKeyDone; //just as an example + textView.font = [UIFont systemFontOfSize:16.0f]; + textView.delegate = self; + textView.internalTextView.scrollIndicatorInsets = UIEdgeInsetsMake(7, 0, 5, 0); + if (counts!=3) + { + textView.backgroundColor = [UIColor clearColor]; + }else{ + textView.backgroundColor = [UIColor whiteColor]; + + } + + textView.text = placeholderText; + [textView becomeFirstResponder]; + + NSLog(@"%@",dialogETBg); + UIImage * rawEntryBackground = [UIImage imageWithContentsOfFile:dialogETBg]; + UIImage *entryBackground = [rawEntryBackground stretchableImageWithLeftCapWidth:13 topCapHeight:22]; + entryImageView = [[[UIImageView alloc] initWithImage:entryBackground] autorelease]; + entryImageView.userInteractionEnabled = YES; + entryImageView.frame = CGRectMake(10, 0, mainWidth-82, 40); + entryImageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; + + UIImage *rawBackground = [UIImage imageNamed:dialogETBg]; + UIImage *background = [rawBackground stretchableImageWithLeftCapWidth:13 topCapHeight:22]; + UIImageView *imageView = [[[UIImageView alloc] initWithImage:background] autorelease]; + imageView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height); + imageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; + imageView.userInteractionEnabled = YES; + textView.autoresizingMask = UIViewAutoresizingFlexibleWidth; + + // view hierachy + // [self addSubview:imageView]; + [self addSubview:entryImageView]; + + [self addSubview:textView]; + + UIImage *sendBtnBackground = [[UIImage imageWithContentsOfFile:dialogButBg] stretchableImageWithLeftCapWidth:13 topCapHeight:0]; + UIImage *selectedSendBtnBackground = [[UIImage imageWithContentsOfFile:dialogButBg] stretchableImageWithLeftCapWidth:13 topCapHeight:0]; + + doneBtn = [UIButton buttonWithType:UIButtonTypeCustom]; + doneBtn.frame = CGRectMake(self.frame.size.width - 62, 0,55 , 40); + doneBtn.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin; + [doneBtn setTitleShadowColor:[UIColor colorWithWhite:0 alpha:0.4] forState:UIControlStateNormal]; + doneBtn.titleLabel.shadowOffset = CGSizeMake (0.0, -1.0); + doneBtn.titleLabel.font = [UIFont boldSystemFontOfSize:18.0f]; + NSLog(@"旋转--前--的位置:%@",NSStringFromCGRect(doneBtn.frame)); + + if ([btnString length]==0) { + [doneBtn setTitle:@"确定" forState:UIControlStateNormal]; + }else { + [doneBtn setTitle:btnString forState:UIControlStateNormal]; + } + + [doneBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; + [doneBtn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside]; + [doneBtn setBackgroundImage:sendBtnBackground forState:UIControlStateNormal]; + [doneBtn setBackgroundImage:selectedSendBtnBackground forState:UIControlStateSelected]; + [self addSubview:doneBtn]; + + self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin; + }else { - [doneBtn setTitle:btnString forState:UIControlStateNormal]; - } - [doneBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; - [doneBtn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside]; - [doneBtn setBackgroundImage:sendBtnBackground forState:UIControlStateNormal]; - [doneBtn setBackgroundImage:selectedSendBtnBackground forState:UIControlStateSelected]; - [self addSubview:doneBtn]; - - - self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin; + + int width = [EUtility screenWidth]; + int height =[EUtility screenHeight]; + + int realwidth = MAX(width, height); + int realheight = MIN(width, height); -} + view = [[UIView alloc]initWithFrame:CGRectMake(0, 2, realwidth, 60)]; + NSLog(@"旋转之前的:%@",NSStringFromCGRect(view.frame)); + view.backgroundColor = [UIColor whiteColor]; + [self addSubview:view]; + + textView = [[PLGrowingTextView alloc] initWithFrame:CGRectMake(11, 10, mainWidth - 80, 40)]; + textView.contentInset = UIEdgeInsetsMake(0, 5, 0, 5); + textView.minNumberOfLines = 1; + if (isLandspace) { + textView.maxNumberOfLines = 4; + } else { + textView.maxNumberOfLines = 6; + } + + switch (keyBoardType) { + case StandardKB: + break; + case NumberKB: + [textView.internalTextView setKeyboardType:UIKeyboardTypeNumberPad]; + break; + case EmailKB: + [textView.internalTextView setKeyboardType:UIKeyboardTypeEmailAddress]; + break; + case URLKB: + [textView.internalTextView setKeyboardType:UIKeyboardTypeURL]; + break; + case PassWordKB: + textView.internalTextView.secureTextEntry = YES; + break; + /*case 5: + [textView.internalTextView setKeyboardType:UIKeyboardTypeASCIICapable]; + break; + case 6: + [textView.internalTextView setKeyboardType:UIKeyboardTypeNumbersAndPunctuation]; + break; + case 7: + [textView.internalTextView setKeyboardType:UIKeyboardTypePhonePad]; + break; + case 8: + [textView.internalTextView setKeyboardType:UIKeyboardTypeNamePhonePad]; + break; + case 9: + [textView.internalTextView setKeyboardType:UIKeyboardTypeDecimalPad]; + break; */ + default: + break; + } + + textView.returnKeyType = UIReturnKeyDone; //just as an example + textView.font = [UIFont systemFontOfSize:16.0f]; + textView.delegate = self; + textView.internalTextView.scrollIndicatorInsets = UIEdgeInsetsMake(7, 0, 5, 0); + if (counts!=3) + { + textView.backgroundColor = [UIColor clearColor]; + }else{ + textView.backgroundColor = [UIColor whiteColor]; + + } + + textView.text = placeholderText; + [textView becomeFirstResponder]; + + NSLog(@"%@",dialogETBg); + UIImage * rawEntryBackground = [UIImage imageWithContentsOfFile:dialogETBg]; + UIImage *entryBackground = [rawEntryBackground stretchableImageWithLeftCapWidth:13 topCapHeight:22]; + entryImageView = [[[UIImageView alloc] initWithImage:entryBackground] autorelease]; + entryImageView.userInteractionEnabled = YES; + entryImageView.frame = CGRectMake(10, 10, realwidth-82, 40); + entryImageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; + + UIImage *rawBackground = [UIImage imageNamed:dialogETBg]; + UIImage *background = [rawBackground stretchableImageWithLeftCapWidth:13 topCapHeight:22]; + UIImageView *imageView = [[[UIImageView alloc] initWithImage:background] autorelease]; + imageView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height); + imageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; + imageView.userInteractionEnabled = YES; + textView.autoresizingMask = UIViewAutoresizingFlexibleWidth; + + // view hierachy + // [self addSubview:imageView]; + [self addSubview:entryImageView]; + + [self addSubview:textView]; + + UIImage *sendBtnBackground = [[UIImage imageWithContentsOfFile:dialogButBg] stretchableImageWithLeftCapWidth:13 topCapHeight:0]; + UIImage *selectedSendBtnBackground = [[UIImage imageWithContentsOfFile:dialogButBg] stretchableImageWithLeftCapWidth:13 topCapHeight:0]; + + doneBtn = [UIButton buttonWithType:UIButtonTypeCustom]; + doneBtn.frame = CGRectMake(self.frame.size.width - 62, 10,55 , 40); + doneBtn.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin; + [doneBtn setTitleShadowColor:[UIColor colorWithWhite:0 alpha:0.4] forState:UIControlStateNormal]; + doneBtn.titleLabel.shadowOffset = CGSizeMake (0.0, -1.0); + doneBtn.titleLabel.font = [UIFont boldSystemFontOfSize:18.0f]; + if ([btnString length]==0) { + [doneBtn setTitle:@"确定" forState:UIControlStateNormal]; + }else { + [doneBtn setTitle:btnString forState:UIControlStateNormal]; + } + + [doneBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; + [doneBtn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside]; + [doneBtn setBackgroundImage:sendBtnBackground forState:UIControlStateNormal]; + [doneBtn setBackgroundImage:selectedSendBtnBackground forState:UIControlStateSelected]; + [self addSubview:doneBtn]; + + self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin; + + } + +// [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doRotate) name:UIDeviceOrientationDidChangeNotification object:nil]; + + } -(void)btnClick { [textView resignFirstResponder]; @@ -186,7 +369,21 @@ -(void) keyboardWillShow:(NSNotification *)note{ // get a rect for the textView frame CGRect containerFrame = self.frame; - containerFrame.origin.y = mainHeight - (keyboardBounds.size.height + containerFrame.size.height); + int width = [EUtility screenWidth]; + int height =[EUtility screenHeight]; + + int realwidth = MAX(width, height); + int realheight = MIN(width, height); + UIInterfaceOrientation deviceOrientation = [[UIApplication sharedApplication] statusBarOrientation]; + if (deviceOrientation == UIInterfaceOrientationPortrait || deviceOrientation == UIInterfaceOrientationPortraitUpsideDown) + { + containerFrame.origin.y = realwidth-30 - (keyboardBounds.size.height + containerFrame.size.height); + + }else{ + + containerFrame.origin.y = realheight-30 - (keyboardBounds.size.height + containerFrame.size.height); + + } // animations settings [UIView beginAnimations:nil context:NULL]; [UIView setAnimationBeginsFromCurrentState:YES]; @@ -222,6 +419,7 @@ -(void) keyboardWillHide:(NSNotification *)note{ } - (void)PLGrowingTextViewDidEndEditing:(PLGrowingTextView *)PLGrowingTextView{ + NSLog(@"PLGrowingTextViewDidEndEditing"); if (_delegate&&[_delegate respondsToSelector:@selector(inputDialogClose)]) { [_delegate inputDialogClose]; } @@ -240,12 +438,6 @@ - (void)PLGrowingTextView:(PLGrowingTextView *)PLGrowingTextView willChangeHeigh self.frame = r; } --(void)dealloc { - [self removeKeyboardNotifucations]; - [super dealloc]; -} - - // Only override drawRect: if you perform custom drawing. // An empty implementation adversely affects performance during animation. /* diff --git a/EUExControl/EUExControl/sourceCode/MonthDatePicker/.svn/all-wcprops b/EUExControl/EUExControl/sourceCode/MonthDatePicker/.svn/all-wcprops new file mode 100644 index 0000000..7430f1b --- /dev/null +++ b/EUExControl/EUExControl/sourceCode/MonthDatePicker/.svn/all-wcprops @@ -0,0 +1,29 @@ +K 25 +svn:wc:ra_dav:version-url +V 138 +/svn/Plugin3.0_IOS/!svn/ver/2581/branches/chenjian_Plugin3.0_IOS_20150512-1/code/public/EUExControl/EUExControl/sourceCode/MonthDatePicker +END +CDatePickerViewEx.m +K 25 +svn:wc:ra_dav:version-url +V 158 +/svn/Plugin3.0_IOS/!svn/ver/2581/branches/chenjian_Plugin3.0_IOS_20150512-1/code/public/EUExControl/EUExControl/sourceCode/MonthDatePicker/CDatePickerViewEx.m +END +MonthPicker.h +K 25 +svn:wc:ra_dav:version-url +V 152 +/svn/Plugin3.0_IOS/!svn/ver/2581/branches/chenjian_Plugin3.0_IOS_20150512-1/code/public/EUExControl/EUExControl/sourceCode/MonthDatePicker/MonthPicker.h +END +CDatePickerViewEx.h +K 25 +svn:wc:ra_dav:version-url +V 158 +/svn/Plugin3.0_IOS/!svn/ver/2581/branches/chenjian_Plugin3.0_IOS_20150512-1/code/public/EUExControl/EUExControl/sourceCode/MonthDatePicker/CDatePickerViewEx.h +END +MonthPicker.m +K 25 +svn:wc:ra_dav:version-url +V 152 +/svn/Plugin3.0_IOS/!svn/ver/2581/branches/chenjian_Plugin3.0_IOS_20150512-1/code/public/EUExControl/EUExControl/sourceCode/MonthDatePicker/MonthPicker.m +END diff --git a/EUExControl/EUExControl/sourceCode/MonthDatePicker/.svn/entries b/EUExControl/EUExControl/sourceCode/MonthDatePicker/.svn/entries new file mode 100644 index 0000000..414c92f --- /dev/null +++ b/EUExControl/EUExControl/sourceCode/MonthDatePicker/.svn/entries @@ -0,0 +1,164 @@ +10 + +dir +2584 +https://chen.jian@192.168.1.38/svn/Plugin3.0_IOS/branches/chenjian_Plugin3.0_IOS_20150512-1/code/public/EUExControl/EUExControl/sourceCode/MonthDatePicker +https://chen.jian@192.168.1.38/svn/Plugin3.0_IOS + + + +2015-07-13T09:31:01.191233Z +2581 +chen.jian + + + + + + + + + + + + + + +fe83e642-6d5d-e244-a357-a2cfeee71fe4 + +CDatePickerViewEx.m +file + + + + +2015-07-14T11:06:07.000000Z +e0462b6885c54ea058fd5029fbb4d9e0 +2015-07-13T09:31:01.191233Z +2581 +chen.jian +has-props + + + + + + + + + + + + + + + + + + + + +11093 + +MonthPicker.h +file + + + + +2015-07-14T11:06:07.000000Z +34175b55b70d67eb769de6fec0a5f31e +2015-07-13T09:31:01.191233Z +2581 +chen.jian + + + + + + + + + + + + + + + + + + + + + +1068 + +CDatePickerViewEx.h +file + + + + +2015-07-14T11:06:07.000000Z +b713a637042d78d3deec5691380ae7d9 +2015-07-13T09:31:01.191233Z +2581 +chen.jian +has-props + + + + + + + + + + + + + + + + + + + + +985 + +MonthPicker.m +file + + + + +2015-07-14T11:06:07.000000Z +093cf51c25ced985f2b02bef8c27ba2f +2015-07-13T09:31:01.191233Z +2581 +chen.jian + + + + + + + + + + + + + + + + + + + + + +12378 + diff --git a/EUExControl/EUExControl/sourceCode/MonthDatePicker/.svn/prop-base/CDatePickerViewEx.h.svn-base b/EUExControl/EUExControl/sourceCode/MonthDatePicker/.svn/prop-base/CDatePickerViewEx.h.svn-base new file mode 100644 index 0000000..a669705 --- /dev/null +++ b/EUExControl/EUExControl/sourceCode/MonthDatePicker/.svn/prop-base/CDatePickerViewEx.h.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 0 + +END diff --git a/EUExControl/EUExControl/sourceCode/MonthDatePicker/.svn/prop-base/CDatePickerViewEx.m.svn-base b/EUExControl/EUExControl/sourceCode/MonthDatePicker/.svn/prop-base/CDatePickerViewEx.m.svn-base new file mode 100644 index 0000000..a669705 --- /dev/null +++ b/EUExControl/EUExControl/sourceCode/MonthDatePicker/.svn/prop-base/CDatePickerViewEx.m.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 0 + +END diff --git a/EUExControl/EUExControl/sourceCode/MonthDatePicker/.svn/text-base/CDatePickerViewEx.h.svn-base b/EUExControl/EUExControl/sourceCode/MonthDatePicker/.svn/text-base/CDatePickerViewEx.h.svn-base new file mode 100644 index 0000000..96fc75a --- /dev/null +++ b/EUExControl/EUExControl/sourceCode/MonthDatePicker/.svn/text-base/CDatePickerViewEx.h.svn-base @@ -0,0 +1,32 @@ +// +// CDatePickerViewEx.h +// MonthYearDatePicker +// +// Created by Igor on 18.03.13. +// Copyright (c) 2013 Igor. All rights reserved. +// + +@interface CDatePickerViewEx : UIPickerView + +@property (nonatomic, strong) UIColor *monthSelectedTextColor; +@property (nonatomic, strong) UIColor *monthTextColor; + +@property (nonatomic, strong) UIColor *yearSelectedTextColor; +@property (nonatomic, strong) UIColor *yearTextColor; + +@property (nonatomic, strong) UIFont *monthSelectedFont; +@property (nonatomic, strong) UIFont *monthFont; + +@property (nonatomic, strong) UIFont *yearSelectedFont; +@property (nonatomic, strong) UIFont *yearFont; + +@property (nonatomic, assign) NSInteger rowHeight; + +@property (nonatomic, strong, readonly) NSDate *date; + +@property (nonatomic, strong) NSDate *resultDate; + +-(void)setupMinYear:(NSInteger)minYear maxYear:(NSInteger)maxYear; +-(void)selectTodayWithYear:(NSInteger )year andMonth:(NSInteger )month ; + +@end diff --git a/EUExControl/EUExControl/sourceCode/MonthDatePicker/.svn/text-base/CDatePickerViewEx.m.svn-base b/EUExControl/EUExControl/sourceCode/MonthDatePicker/.svn/text-base/CDatePickerViewEx.m.svn-base new file mode 100644 index 0000000..c87690f --- /dev/null +++ b/EUExControl/EUExControl/sourceCode/MonthDatePicker/.svn/text-base/CDatePickerViewEx.m.svn-base @@ -0,0 +1,445 @@ +// +// CDatePickerViewEx.m +// MonthYearDatePicker +// +// Created by Igor on 18.03.13. +// Copyright (c) 2013 Igor. All rights reserved. +// + +#import "CDatePickerViewEx.h" + +// Identifiers of components +#define MONTH ( 1 ) +#define YEAR ( 0 ) + + +// Identifies for component views +#define LABEL_TAG 43 + + +@interface CDatePickerViewEx() + +@property (nonatomic, strong) NSIndexPath *todayIndexPath; +@property (nonatomic, strong) NSArray *months; +@property (nonatomic, strong) NSArray *years; + +@property (nonatomic, assign) NSInteger minYear; +@property (nonatomic, assign) NSInteger maxYear; + +@property (nonatomic, strong) NSDateComponents *components ; + +@end + +@implementation CDatePickerViewEx + +const NSInteger bigRowCount = 1000; +const NSInteger numberOfComponents = 2; + +#pragma mark - Properties + +-(void)setMonthFont:(UIFont *)monthFont +{ + if (monthFont) + { + _monthFont = monthFont; + } +} + +-(void)setMonthSelectedFont:(UIFont *)monthSelectedFont +{ + if (monthSelectedFont) + { + _monthSelectedFont = monthSelectedFont; + } +} + +-(void)setYearFont:(UIFont *)yearFont +{ + if (yearFont) + { + _yearFont = yearFont; + } +} + +-(void)setYearSelectedFont:(UIFont *)yearSelectedFont +{ + if (yearSelectedFont) + { + _yearSelectedFont = yearSelectedFont; + } +} + +#pragma mark - Init + +-(instancetype)init +{ + if (self = [super init]) + { + [self loadDefaultsParameters]; + } + return self; +} + +-(instancetype)initWithFrame:(CGRect)frame +{ + if (self = [super initWithFrame:frame]) + { + [self loadDefaultsParameters]; + } + return self; +} + +-(void)awakeFromNib +{ + [super awakeFromNib]; + + [self loadDefaultsParameters]; +} + +#pragma mark - Open methods + +-(NSDate *)date +{ + NSInteger monthCount = self.months.count; + NSString *month = [self.months objectAtIndex:([self selectedRowInComponent:MONTH] % monthCount)]; + + NSInteger yearCount = self.years.count; + NSString *year = [self.years objectAtIndex:([self selectedRowInComponent:YEAR] % yearCount)]; + + NSDateFormatter *formatter = [NSDateFormatter new]; + [formatter setDateFormat:@"MMMM:yyyy"]; + NSDate *date = [formatter dateFromString:[NSString stringWithFormat:@"%@:%@", month, year]]; + return date; +} + +- (void)setupMinYear:(NSInteger)minYear maxYear:(NSInteger)maxYear +{ + self.minYear = minYear; + + if (maxYear > minYear) + { + self.maxYear = maxYear; + } + else + { + self.maxYear = minYear + 10; + } + + self.years = [self nameOfYears]; + self.todayIndexPath = [self todayPath]; +} + +-(void)selectTodayWithYear:( NSInteger )year andMonth:(NSInteger )month +{ + + CGFloat row = 0.f; + CGFloat section = 0.f; + + NSString *mon =[NSString stringWithFormat:@"%d",month]; + mon = [NSString stringWithFormat:@"%@月",mon]; + NSString *ye = [NSString stringWithFormat:@"%d",year]; + ye = [NSString stringWithFormat:@"%@年",ye]; + + + //set table on the middle + for(NSString *cellMonth in self.months) + { + if([cellMonth isEqualToString:mon]) + { + row = [self.months indexOfObject:cellMonth]; + row = row + [self bigRowMonthCount] / 2; + break; + } + } + + for(NSString *cellYear in self.years) + { + if([cellYear isEqualToString: ye]) + { + section = [self.years indexOfObject:cellYear]; + section = section + [self bigRowYearCount] / 2; + break; + } + } + + + if (year) { + [self selectRow: [NSIndexPath indexPathForRow:row inSection:section].section + inComponent: YEAR + animated: NO]; + }else{ + [self selectRow: self.todayIndexPath.section + inComponent: YEAR + animated: NO]; + } + + if (month) { + [self selectRow: [NSIndexPath indexPathForRow:row inSection:section].row + inComponent: MONTH + animated: NO]; + }else{ + [self selectRow: self.todayIndexPath.row + inComponent: MONTH + animated: NO]; + } + + _components.month = month; + _components.year = year; + _resultDate = [[NSCalendar currentCalendar] dateFromComponents:_components]; +} + +#pragma mark - UIPickerViewDelegate + +-(CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component +{ + return [self componentWidth]; +} + +-(UIView *)pickerView: (UIPickerView *)pickerView viewForRow: (NSInteger)row forComponent: (NSInteger)component reusingView: (UIView *)view +{ + BOOL selected = NO; + if(component == MONTH) + { + NSInteger monthCount = self.months.count; + NSString *monthName = [self.months objectAtIndex:(row % monthCount)]; + NSString *currentMonthName = [self currentMonthName]; + if([monthName isEqualToString:currentMonthName] == YES) + { + selected = YES; + } + } + else + { + NSInteger yearCount = self.years.count; + NSString *yearName = [self.years objectAtIndex:(row % yearCount)]; + NSString *currenrYearName = [self currentYearName]; + if([yearName isEqualToString:currenrYearName] == YES) + { + selected = YES; + } + } + + UILabel *returnView = nil; + if(view.tag == LABEL_TAG) + { + returnView = (UILabel *)view; + } + else + { + returnView = [self labelForComponent:component]; + } + + returnView.font = selected ? [self selectedFontForComponent:component] : [self fontForComponent:component]; + returnView.textColor = selected ? [self selectedColorForComponent:component] : [self colorForComponent:component]; + + returnView.text = [self titleForRow:row forComponent:component]; + return returnView; +} + +-(CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component +{ + return self.rowHeight; +} +- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{ + + + if (component == 1) { + NSLog(@"%@",[self.months objectAtIndex:row%12]); + _components.month = [[self.months objectAtIndex:row%12] integerValue]; + }else{ + NSLog(@"%@",[self.years objectAtIndex:row%(self.years.count)]); + _components.year = [[self.years objectAtIndex:row%(self.years.count)] integerValue]; + } + _resultDate = [[NSCalendar currentCalendar] dateFromComponents:_components]; +} + +#pragma mark - UIPickerViewDataSource + +- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView +{ + return numberOfComponents; +} + +-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component +{ + if(component == MONTH) + { + return [self bigRowMonthCount]; + } + return [self bigRowYearCount]; +} +#pragma mark - Util + +-(NSInteger)bigRowMonthCount +{ + return self.months.count * bigRowCount; +} + +-(NSInteger)bigRowYearCount +{ + return self.years.count * bigRowCount; +} + +-(CGFloat)componentWidth +{ + return self.bounds.size.width / numberOfComponents; +} + +-(NSString *)titleForRow:(NSInteger)row forComponent:(NSInteger)component +{ + if(component == MONTH) + { + NSInteger monthCount = self.months.count; + return [self.months objectAtIndex:(row % monthCount)]; + } + NSInteger yearCount = self.years.count; + return [self.years objectAtIndex:(row % yearCount)]; +} + +-(UILabel *)labelForComponent:(NSInteger)component +{ + CGRect frame = CGRectMake(0, 0, [self componentWidth], self.rowHeight); + + UILabel *label = [[UILabel alloc] initWithFrame:frame]; + label.textAlignment = UITextAlignmentCenter; + label.backgroundColor = [UIColor clearColor]; + label.userInteractionEnabled = NO; + + label.tag = LABEL_TAG; + + return label; +} + +-(NSArray *)nameOfMonths +{ + return @[@"1月", @"2月", @"3月", @"4月", @"5月", @"6月", @"7月", @"8月", @"9月", @"10月", @"11月", @"12月"]; +} + +-(NSArray *)nameOfYears +{ + NSMutableArray *years = [NSMutableArray array]; + + for(NSInteger year = self.minYear; year <= self.maxYear; year++) + { + NSString *yearStr = [NSString stringWithFormat:@"%li年", (long)year]; + [years addObject:yearStr]; + } + return years; +} + +-(NSIndexPath *)todayPath // row - month ; section - year +{ + CGFloat row = 0.f; + CGFloat section = 0.f; + + NSString *month = [self currentMonthName]; + + month = [NSString stringWithFormat:@"%@月",month]; + NSString *year = [self currentYearName]; + year = [NSString stringWithFormat:@"%@年",year]; + + //set table on the middle + for(NSString *cellMonth in self.months) + { + if([cellMonth isEqualToString:month]) + { + row = [self.months indexOfObject:cellMonth]; + row = row + [self bigRowMonthCount] / 2; + break; + } + } + + for(NSString *cellYear in self.years) + { + if([cellYear isEqualToString:year]) + { + section = [self.years indexOfObject:cellYear]; + section = section + [self bigRowYearCount] / 2; + break; + } + } + + return [NSIndexPath indexPathForRow:row inSection:section]; +} + +-(NSString *)currentMonthName +{ + NSDateFormatter *formatter = [NSDateFormatter new]; +// NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]; +// [formatter setLocale:usLocale]; + [formatter setDateFormat:@"M"]; + return [formatter stringFromDate:[NSDate date]]; +} + +-(NSString *)currentYearName +{ + NSDateFormatter *formatter = [NSDateFormatter new]; + [formatter setDateFormat:@"yyyy"]; + return [formatter stringFromDate:[NSDate date]]; +} + +- (UIColor *)selectedColorForComponent:(NSInteger)component +{ + if (component == 0) + { + return self.monthSelectedTextColor; + } + return self.yearSelectedTextColor; +} + +- (UIColor *)colorForComponent:(NSInteger)component +{ + if (component == 0) + { + return self.monthTextColor; + } + return self.yearTextColor; +} + +- (UIFont *)selectedFontForComponent:(NSInteger)component +{ + if (component == 0) + { + return self.monthSelectedFont; + } + return self.yearSelectedFont; +} + +- (UIFont *)fontForComponent:(NSInteger)component +{ + if (component == 0) + { + return self.monthFont; + } + return self.yearFont; +} + +-(void)loadDefaultsParameters +{ + self.minYear = 1879; + self.maxYear = 2050; + self.rowHeight = 44; + + self.months = [self nameOfMonths]; + self.years = [self nameOfYears]; + self.todayIndexPath = [self todayPath]; + + self.delegate = self; + self.dataSource = self; + + self.monthSelectedTextColor = [UIColor blueColor]; + self.monthTextColor = [UIColor blackColor]; + + self.yearSelectedTextColor = [UIColor blueColor]; + self.yearTextColor = [UIColor blackColor]; + + self.monthSelectedFont = [UIFont boldSystemFontOfSize:17]; + self.monthFont = [UIFont boldSystemFontOfSize:17]; + self.yearSelectedFont = [UIFont boldSystemFontOfSize:17]; + self.yearFont = [UIFont boldSystemFontOfSize:17]; + + self.components = [[NSDateComponents alloc] init]; + +} + +@end diff --git a/EUExControl/EUExControl/sourceCode/MonthDatePicker/.svn/text-base/MonthPicker.h.svn-base b/EUExControl/EUExControl/sourceCode/MonthDatePicker/.svn/text-base/MonthPicker.h.svn-base new file mode 100644 index 0000000..0feecc9 --- /dev/null +++ b/EUExControl/EUExControl/sourceCode/MonthDatePicker/.svn/text-base/MonthPicker.h.svn-base @@ -0,0 +1,34 @@ +// +// MonthPicker.h +// AppCanPlugin +// +// Created by zhijian du on 15/1/27. +// Copyright (c) 2015年 zywx. All rights reserved. +// + +#import +#import "HeaderView.h" +#import "CDatePickerViewEx.h" +@class EUExControl; + +@interface MonthPicker : NSObject{ + UIView *mainView; + EUExControl *euexObj; + HeaderView *toolView; + NSNumber *pickerType; + CDatePickerViewEx *monthPcikerView; + NSMutableDictionary *selectValue; + UIPopoverController *popcontroller; +} + +@property(nonatomic, retain)UIView *mainView; +@property(nonatomic, assign)EUExControl *euexObj; +@property(nonatomic, retain)HeaderView *toolView; +@property(nonatomic, assign)NSNumber *pickerType; +@property(nonatomic, retain)CDatePickerViewEx *monthPcikerView; +@property(nonatomic, retain)NSMutableDictionary *selectValue; +@property(nonatomic, retain)UIPopoverController *popController; + +-(id)initWithEuex:(EUExControl *)euexObj_; +-(void)showMonthPickerWithType:(int)type date:(NSDate *)inDate; +@end diff --git a/EUExControl/EUExControl/sourceCode/MonthDatePicker/.svn/text-base/MonthPicker.m.svn-base b/EUExControl/EUExControl/sourceCode/MonthDatePicker/.svn/text-base/MonthPicker.m.svn-base new file mode 100644 index 0000000..4a12ee7 --- /dev/null +++ b/EUExControl/EUExControl/sourceCode/MonthDatePicker/.svn/text-base/MonthPicker.m.svn-base @@ -0,0 +1,274 @@ +// +// MonthPicker.m +// AppCanPlugin +// +// Created by zhijian du on 15/1/27. +// Copyright (c) 2015年 zywx. All rights reserved. +// + +#import "MonthPicker.h" +#import "EUtility.h" +#import "JSON.h" +#import "EUExBaseDefine.h" +#import "EUExControl.h" +#define MAIN_HEIGHT 202 +#define HEAD_HEIGHT 40 +#define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + +#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width) +#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height) +@implementation MonthPicker +@synthesize pickerType; +@synthesize mainView; +@synthesize euexObj; +@synthesize toolView; +@synthesize selectValue; +@synthesize monthPcikerView; +@synthesize popController; + +-(id)initWithEuex:(EUExControl *)euexObj_{ + self.euexObj = euexObj_; + return self; +} +-(void)setResultFormat:(NSDate *)inDate{ + NSLog(@"DatePicker setResultFormat start"); + NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; + + NSInteger unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSWeekdayCalendarUnit | + NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit; + + NSDateComponents *comps = [calendar components:unitFlags fromDate:inDate]; + + int year = [comps year]; + int month = [comps month]; + + [calendar release]; + + [selectValue setObject:[NSNumber numberWithInt:year] forKey:UEX_JKYEAR]; + [selectValue setObject:[NSNumber numberWithInt:month] forKey:UEX_JKMONTH]; + + NSLog(@"DatePicker setResultFormat end"); +} +- (void)changeDate:(id)sender{ + NSDate *checkDate = monthPcikerView.resultDate; + [self setResultFormat:checkDate]; +} +-(void)doRotate{ +// if ([EUtility isIpad]) { +// return; +// } + if (isPad) + { + UIInterfaceOrientation deviceOrientation = [[UIApplication sharedApplication] statusBarOrientation]; + if (deviceOrientation == UIInterfaceOrientationPortrait||deviceOrientation == UIInterfaceOrientationPortraitUpsideDown) { + [mainView setFrame:CGRectMake(0, [EUtility screenWidth]-MAIN_HEIGHT, 320, MAIN_HEIGHT)]; + [toolView setFrame:CGRectMake(0, 0,[EUtility screenWidth], 40)]; + [toolView.lay setFrame:CGRectMake(0, 0,[EUtility screenWidth], 40)]; + [toolView.cancle setFrame:CGRectMake(5, 5, 41, 30)]; + // toolView.backgroundColor = [UIColor grayColor]; + + [toolView.confirm setFrame:CGRectMake([EUtility screenWidth]-70, 5, 41, 30)]; + [monthPcikerView setFrame:CGRectMake(0, 40, [EUtility screenWidth], MAIN_HEIGHT-40)]; + }else if (deviceOrientation == UIInterfaceOrientationLandscapeLeft||deviceOrientation==UIInterfaceOrientationLandscapeRight){ + [mainView setFrame:CGRectMake(0, ([UIScreen mainScreen].bounds.size.height)-MAIN_HEIGHT, [UIScreen mainScreen].bounds.size.width, MAIN_HEIGHT)]; + [toolView setFrame:CGRectMake(0, 0, [EUtility screenHeight], 40)]; + toolView.backgroundColor = [UIColor grayColor]; + [toolView.lay setFrame:CGRectMake(0, 0, [EUtility screenHeight], 40)]; + [toolView.confirm setFrame:CGRectMake([EUtility screenWidth] - 36, 5, 41, 30)]; + //toolView.confirm.backgroundColor = [UIColor redColor]; + [toolView.cancle setFrame:CGRectMake(5, 5, 41, 30)]; +// toolView.cancle.backgroundColor = [UIColor grayColor]; + [monthPcikerView setFrame:CGRectMake(0, 40, [EUtility screenHeight]-MAIN_HEIGHT, MAIN_HEIGHT-40)]; + } +//手机版; + }else{ + UIInterfaceOrientation deviceOrientation = [[UIApplication sharedApplication] statusBarOrientation]; + if (deviceOrientation == UIInterfaceOrientationPortrait||deviceOrientation == UIInterfaceOrientationPortraitUpsideDown) { + [mainView setFrame:CGRectMake(0, [EUtility screenHeight]-MAIN_HEIGHT, 320, MAIN_HEIGHT)]; + [toolView setFrame:CGRectMake(0, 0, 320, 40)]; + [toolView.lay setFrame:CGRectMake(0, 0, 320, 40)]; + [toolView.cancle setFrame:CGRectMake(5, 5, 41, 30)]; + [toolView.confirm setFrame:CGRectMake(320 - 46, 5, 41, 30)]; + [monthPcikerView setFrame:CGRectMake(0, 40, 320, MAIN_HEIGHT-40)]; + }else if (deviceOrientation == UIInterfaceOrientationLandscapeLeft||deviceOrientation==UIInterfaceOrientationLandscapeRight){ + [mainView setFrame:CGRectMake(0, ([UIScreen mainScreen].bounds.size.height)-MAIN_HEIGHT, [UIScreen mainScreen].bounds.size.width, MAIN_HEIGHT)]; + [toolView setFrame:CGRectMake(0, 0, [EUtility screenWidth], 40)]; + [toolView.lay setFrame:CGRectMake(0, 0, [EUtility screenWidth], 40)]; + [toolView.confirm setFrame:CGRectMake([EUtility screenWidth] - 46, 5, 41, 30)]; + + [toolView.cancle setFrame:CGRectMake(5, 5, 41, 30)]; + toolView.backgroundColor = [UIColor grayColor]; + [monthPcikerView setFrame:CGRectMake(0, 40, [EUtility screenWidth], MAIN_HEIGHT-40)]; + } + + } + +} + +-(void)showMonthPickerWithType:(int)type date:(NSDate *)inDate{ + NSLog(@"DatePicker showMonthPickerWithType start"); + if (mainView) { + return; + } + self.pickerType = [NSNumber numberWithInt:type]; + NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:10]; + self.selectValue = dict; + [dict release]; + [self setResultFormat:inDate]; + + UIInterfaceOrientation deviceOrientation = [[UIApplication sharedApplication] statusBarOrientation]; + if ( deviceOrientation == UIInterfaceOrientationPortrait || deviceOrientation == UIInterfaceOrientationPortraitUpsideDown) { + self.mainView = [[[UIView alloc] initWithFrame:CGRectMake(0, [EUtility screenHeight], [UIScreen mainScreen].bounds.size.width, MAIN_HEIGHT)] autorelease]; + self.toolView = [[[HeaderView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 40)] autorelease]; + self.toolView.confirm.frame = CGRectMake(self.mainView.frame.size.width-65, 5, 41, 30); + self.monthPcikerView = [[[CDatePickerViewEx alloc] init] autorelease]; + [monthPcikerView setFrame:CGRectMake(0, 40, [UIScreen mainScreen].bounds.size.width, MAIN_HEIGHT-40)]; + }else { + self.mainView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, MAIN_HEIGHT)] autorelease]; + + self.toolView = [[[HeaderView alloc] initWithFrame:CGRectMake(0, 0,[UIScreen mainScreen].bounds.size.width, 40)] autorelease]; + self.toolView.confirm.frame = CGRectMake(self.mainView.frame.size.width-55, 5, 41, 30); + self.monthPcikerView = [[[CDatePickerViewEx alloc] init] autorelease]; + [monthPcikerView setFrame:CGRectMake(0, 40,[UIScreen mainScreen].bounds.size.width, MAIN_HEIGHT-40)]; + } + toolView.delegate = self; + + NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; + + NSInteger unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSWeekdayCalendarUnit | + NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit; + NSDateComponents *comps = [calendar components:unitFlags fromDate:inDate]; + [calendar release]; + NSInteger year = [comps year]; + NSInteger month = [comps month]; + + [monthPcikerView selectTodayWithYear:year andMonth:month]; + + [mainView addSubview:toolView]; + [mainView setBackgroundColor:[UIColor whiteColor]]; + [mainView addSubview:monthPcikerView]; + if (![EUtility isIpad] || SCREEN_WIDTH == 320) { + [EUtility brwView:euexObj.meBrwView addSubview:mainView]; + if (euexObj.meBrwView) { + if (![EUtility isIpad] || deviceOrientation == UIInterfaceOrientationPortrait || deviceOrientation == UIInterfaceOrientationPortraitUpsideDown) { + [UIView animateWithDuration:0.3 animations:^{ + [mainView setFrame:CGRectMake(0, [EUtility screenHeight]-MAIN_HEIGHT, [UIScreen mainScreen].bounds.size.width, MAIN_HEIGHT)]; + }]; + } + [(UIView*)euexObj.meBrwView setUserInteractionEnabled:NO]; + } + }else { + UIViewController *controller = [[UIViewController alloc] init]; + controller.view = mainView; + UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:controller]; + [controller release]; + self.popController = popover; + [popover release]; + + [popController setPopoverContentSize:CGSizeMake([UIScreen mainScreen].bounds.size.width, MAIN_HEIGHT)]; + [popController setDelegate:self]; + //让pop窗口的位置在中间 + int x = SCREEN_WIDTH/2; + int y = (SCREEN_HEIGHT-20)/2; + [EUtility brwView:euexObj.meBrwView presentPopover:popController FromRect:CGRectMake(x, y, 10, 10) permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; + } + if (isPad) + { + + }else{ + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doRotate) name:UIDeviceOrientationDidChangeNotification object:nil]; + + } + + +} + +-(BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController{ + [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil]; + if (mainView) { + [mainView removeFromSuperview]; + } + return YES; +} + +- (void)cancled:(id)headerView{ + if (euexObj.meBrwView) { + [(UIView*)euexObj.meBrwView setUserInteractionEnabled:YES]; + } + + if (![EUtility isIpad] || SCREEN_WIDTH == 320) { + [UIView animateWithDuration:0.3 animations:^{ + [mainView setFrame:CGRectMake(0, [EUtility screenHeight], 320, MAIN_HEIGHT)]; + } completion:^(BOOL finish){ + if (finish) { + [mainView removeFromSuperview]; + } + }]; + } + [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil]; + if (popController) { + [self.popController dismissPopoverAnimated:YES]; + self.popController = nil; + } +} + +- (void)confirm:(id)headerView{ + if (euexObj.meBrwView) { + [(UIView*)euexObj.meBrwView setUserInteractionEnabled:YES]; + } + + NSDate *checkDate = monthPcikerView.resultDate; + [self setResultFormat:checkDate]; + + // NSLog(@"selectValue = %@",[selectValue description]); + [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil]; +// if ([pickerType intValue]==0) { +// [euexObj uexOpenDatePickerWithOpId:0 dataType:UEX_CALLBACK_DATATYPE_JSON data:[selectValue JSONFragment]]; +// }else if ([pickerType intValue]==1) { +// [euexObj uexOpenTimerPickerWithOpId:0 dataType:UEX_CALLBACK_DATATYPE_JSON data:[selectValue JSONFragment]]; +// }else{ + [euexObj uexOpenMonthPickerWithOpId:0 dataType:UEX_CALLBACK_DATATYPE_JSON data:[selectValue JSONFragment]]; +// } + + if (![EUtility isIpad] || SCREEN_WIDTH == 320) { + [UIView animateWithDuration:0.3 animations:^{ + [mainView setFrame:CGRectMake(0, [EUtility screenHeight], 320, MAIN_HEIGHT)]; + } completion:^(BOOL finish){ + if (finish) { + [mainView removeFromSuperview]; + } + }]; + } + if (popController) { + [self.popController dismissPopoverAnimated:YES]; + self.popController = nil; + } +} + +-(void)dealloc{ + NSLog(@"hui--->DatePicker dealloc"); + [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil]; + if (popController) { + NSLog(@"hui--->DatePicker dealloc self.popController retaincount is %d",[self.popController retainCount]); + self.popController = nil; + } + if (monthPcikerView) { + NSLog(@"hui--->DatePicker dealloc pickerView"); + self.monthPcikerView = nil; + } + if (toolView) { + NSLog(@"hui--->DatePicker dealloc toolView"); + self.toolView.delegate = nil; + self.toolView = nil; + } + if (mainView) { + NSLog(@"hui--->DatePicker dealloc mainView"); + self.mainView = nil; + } + if (selectValue) { + NSLog(@"hui--->DatePicker dealloc selectValue"); + self.selectValue = nil; + } + [super dealloc]; +} +@end diff --git a/EUExControl/EUExControl/sourceCode/MonthDatePicker/CDatePickerViewEx.h b/EUExControl/EUExControl/sourceCode/MonthDatePicker/CDatePickerViewEx.h index dff6db4..96fc75a 100755 --- a/EUExControl/EUExControl/sourceCode/MonthDatePicker/CDatePickerViewEx.h +++ b/EUExControl/EUExControl/sourceCode/MonthDatePicker/CDatePickerViewEx.h @@ -27,6 +27,6 @@ @property (nonatomic, strong) NSDate *resultDate; -(void)setupMinYear:(NSInteger)minYear maxYear:(NSInteger)maxYear; --(void)selectTodayWithYear:(NSInteger )year andMonth:(NSInteger )month; +-(void)selectTodayWithYear:(NSInteger )year andMonth:(NSInteger )month ; @end diff --git a/EUExControl/EUExControl/sourceCode/MonthDatePicker/CDatePickerViewEx.m b/EUExControl/EUExControl/sourceCode/MonthDatePicker/CDatePickerViewEx.m index d2b9d47..c87690f 100755 --- a/EUExControl/EUExControl/sourceCode/MonthDatePicker/CDatePickerViewEx.m +++ b/EUExControl/EUExControl/sourceCode/MonthDatePicker/CDatePickerViewEx.m @@ -140,6 +140,7 @@ -(void)selectTodayWithYear:( NSInteger )year andMonth:(NSInteger )month NSString *ye = [NSString stringWithFormat:@"%d",year]; ye = [NSString stringWithFormat:@"%@年",ye]; + //set table on the middle for(NSString *cellMonth in self.months) { @@ -243,8 +244,10 @@ - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComp if (component == 1) { + NSLog(@"%@",[self.months objectAtIndex:row%12]); _components.month = [[self.months objectAtIndex:row%12] integerValue]; }else{ + NSLog(@"%@",[self.years objectAtIndex:row%(self.years.count)]); _components.year = [[self.years objectAtIndex:row%(self.years.count)] integerValue]; } _resultDate = [[NSCalendar currentCalendar] dateFromComponents:_components]; @@ -265,7 +268,6 @@ -(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInt } return [self bigRowYearCount]; } - #pragma mark - Util -(NSInteger)bigRowMonthCount @@ -309,8 +311,8 @@ -(UILabel *)labelForComponent:(NSInteger)component } -(NSArray *)nameOfMonths -{ - return @[UEX_LOCALIZEDSTRING(@"1月"),UEX_LOCALIZEDSTRING(@"2月"),UEX_LOCALIZEDSTRING(@"3月"),UEX_LOCALIZEDSTRING(@"4月"),UEX_LOCALIZEDSTRING(@"5月"),UEX_LOCALIZEDSTRING(@"6月"),UEX_LOCALIZEDSTRING(@"7月"),UEX_LOCALIZEDSTRING(@"8月"),UEX_LOCALIZEDSTRING(@"9月"),UEX_LOCALIZEDSTRING(@"10月"),UEX_LOCALIZEDSTRING(@"11月"),UEX_LOCALIZEDSTRING(@"12月")]; +{ + return @[@"1月", @"2月", @"3月", @"4月", @"5月", @"6月", @"7月", @"8月", @"9月", @"10月", @"11月", @"12月"]; } -(NSArray *)nameOfYears @@ -319,7 +321,7 @@ -(NSArray *)nameOfYears for(NSInteger year = self.minYear; year <= self.maxYear; year++) { - NSString *yearStr = [NSString stringWithFormat:@"%li%@",(long)year,UEX_LOCALIZEDSTRING(@"年")]; + NSString *yearStr = [NSString stringWithFormat:@"%li年", (long)year]; [years addObject:yearStr]; } return years; @@ -332,9 +334,9 @@ -(NSIndexPath *)todayPath // row - month ; section - year NSString *month = [self currentMonthName]; - month = [NSString stringWithFormat:UEX_LOCALIZEDSTRING(@"%@月"),month]; + month = [NSString stringWithFormat:@"%@月",month]; NSString *year = [self currentYearName]; - year = [NSString stringWithFormat:@"%@%@",year,UEX_LOCALIZEDSTRING(@"年")]; + year = [NSString stringWithFormat:@"%@年",year]; //set table on the middle for(NSString *cellMonth in self.months) diff --git a/EUExControl/EUExControl/sourceCode/MonthDatePicker/MonthPicker.m b/EUExControl/EUExControl/sourceCode/MonthDatePicker/MonthPicker.m index f6a0349..522849d 100644 --- a/EUExControl/EUExControl/sourceCode/MonthDatePicker/MonthPicker.m +++ b/EUExControl/EUExControl/sourceCode/MonthDatePicker/MonthPicker.m @@ -13,6 +13,8 @@ #import "EUExControl.h" #define MAIN_HEIGHT 202 #define HEAD_HEIGHT 40 +#define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + #define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width) #define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height) @implementation MonthPicker @@ -25,18 +27,11 @@ @implementation MonthPicker @synthesize popController; -(id)initWithEuex:(EUExControl *)euexObj_{ - - if (self = [super init]) { - - self.euexObj = euexObj_; - - } - + self.euexObj = euexObj_; return self; - } - -(void)setResultFormat:(NSDate *)inDate{ + NSLog(@"DatePicker setResultFormat start"); NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSInteger unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSWeekdayCalendarUnit | @@ -52,71 +47,129 @@ -(void)setResultFormat:(NSDate *)inDate{ [selectValue setObject:[NSNumber numberWithInt:year] forKey:UEX_JKYEAR]; [selectValue setObject:[NSNumber numberWithInt:month] forKey:UEX_JKMONTH]; + NSLog(@"DatePicker setResultFormat end"); } - (void)changeDate:(id)sender{ NSDate *checkDate = monthPcikerView.resultDate; [self setResultFormat:checkDate]; } -(void)doRotate{ - if (![mainView isKindOfClass:[UIView class]] || ![toolView isKindOfClass:[HeaderView class]] || ![monthPcikerView isKindOfClass:[CDatePickerViewEx class]]) { - return; - } +// if ([EUtility isIpad]) { +// return; +// } + if (isPad) + { + UIInterfaceOrientation deviceOrientation = [[UIApplication sharedApplication] statusBarOrientation]; + if (deviceOrientation == UIInterfaceOrientationPortrait||deviceOrientation == UIInterfaceOrientationPortraitUpsideDown) { + + int width = [EUtility screenWidth]; + int height =[EUtility screenHeight]; + + int realwidth = MAX(width, height); + int realheight = MIN(width, height); - - if ([EUtility isIpad]) { - [mainView setFrame:CGRectMake(0, [EUtility screenHeight] - MAIN_HEIGHT, 320*APP_DEVICERATIO, MAIN_HEIGHT)]; - [toolView setFrame:CGRectMake(0, 0, 320*APP_DEVICERATIO, 40)]; - [toolView.lay setFrame:CGRectMake(0, 0, 320*APP_DEVICERATIO, 40)]; - [toolView.cancle setFrame:CGRectMake(5, 5, 41, 30)]; - [toolView.confirm setFrame:CGRectMake(320*APP_DEVICERATIO - 46, 5, 41, 30)]; - [monthPcikerView setFrame:CGRectMake(0, 40, 320*APP_DEVICERATIO, MAIN_HEIGHT-40)]; - return; - } - - + [mainView setFrame:CGRectMake(0, realwidth-MAIN_HEIGHT, 320, MAIN_HEIGHT)]; + [toolView setFrame:CGRectMake(0, 0,realheight, 40)]; + [toolView.lay setFrame:CGRectMake(0, 0,realheight, 40)]; + [toolView.cancle setFrame:CGRectMake(5, 5, 41, 30)]; + // toolView.backgroundColor = [UIColor grayColor]; + + [toolView.confirm setFrame:CGRectMake(realheight-70, 5, 41, 30)]; + [monthPcikerView setFrame:CGRectMake(0, 40, realheight, MAIN_HEIGHT-40)]; + }else if (deviceOrientation == UIInterfaceOrientationLandscapeLeft||deviceOrientation==UIInterfaceOrientationLandscapeRight){ + + int width = [EUtility screenWidth]; + int height =[EUtility screenHeight]; + + int realwidth = MAX(width, height); + int realheight = MIN(width, height); + + [mainView setFrame:CGRectMake(0, realheight-MAIN_HEIGHT, realwidth, MAIN_HEIGHT)]; + [toolView setFrame:CGRectMake(0, 0,realwidth, 40)]; + toolView.backgroundColor = [UIColor clearColor]; + [toolView.lay setFrame:CGRectMake(0, 0, realwidth, 40)]; + [toolView.confirm setFrame:CGRectMake(realwidth - 36, 5, 41, 30)]; + //toolView.confirm.backgroundColor = [UIColor redColor]; + [toolView.cancle setFrame:CGRectMake(5, 5, 41, 30)]; +// toolView.cancle.backgroundColor = [UIColor grayColor]; + [monthPcikerView setFrame:CGRectMake(0, 40, realwidth-MAIN_HEIGHT, MAIN_HEIGHT-40)]; + } +//手机版; + }else{ + UIInterfaceOrientation deviceOrientation = [[UIApplication sharedApplication] statusBarOrientation]; + if (deviceOrientation == UIInterfaceOrientationPortrait||deviceOrientation == UIInterfaceOrientationPortraitUpsideDown) { + [mainView setFrame:CGRectMake(0, [EUtility screenHeight]-MAIN_HEIGHT, 320, MAIN_HEIGHT)]; + [toolView setFrame:CGRectMake(0, 0, 320, 40)]; + [toolView.lay setFrame:CGRectMake(0, 0, 320, 40)]; + [toolView.cancle setFrame:CGRectMake(5, 5, 41, 30)]; + [toolView.confirm setFrame:CGRectMake(320 - 46, 5, 41, 30)]; + [monthPcikerView setFrame:CGRectMake(0, 40, 320, MAIN_HEIGHT-40)]; + }else if (deviceOrientation == UIInterfaceOrientationLandscapeLeft||deviceOrientation==UIInterfaceOrientationLandscapeRight){ + [mainView setFrame:CGRectMake(0, ([UIScreen mainScreen].bounds.size.height)-MAIN_HEIGHT, [UIScreen mainScreen].bounds.size.width, MAIN_HEIGHT)]; + [toolView setFrame:CGRectMake(0, 0, [EUtility screenWidth], 40)]; + [toolView.lay setFrame:CGRectMake(0, 0, [EUtility screenWidth], 40)]; + [toolView.confirm setFrame:CGRectMake([EUtility screenWidth] - 46, 5, 41, 30)]; + + [toolView.cancle setFrame:CGRectMake(5, 5, 41, 30)]; + toolView.backgroundColor = [UIColor grayColor]; + [monthPcikerView setFrame:CGRectMake(0, 40, [EUtility screenWidth], MAIN_HEIGHT-40)]; + } - - UIInterfaceOrientation deviceOrientation = [[UIApplication sharedApplication] statusBarOrientation]; - if (deviceOrientation == UIInterfaceOrientationPortrait||deviceOrientation == UIInterfaceOrientationPortraitUpsideDown) { - [mainView setFrame:CGRectMake(0, [EUtility screenHeight]-MAIN_HEIGHT,SCREEN_WIDTH, MAIN_HEIGHT)]; - [toolView setFrame:CGRectMake(0, 0, SCREEN_WIDTH, 40)]; - [toolView.lay setFrame:CGRectMake(0, 0, SCREEN_WIDTH, 40)]; - [toolView.cancle setFrame:CGRectMake(5, 5, 41, 30)]; - [toolView.confirm setFrame:CGRectMake(SCREEN_WIDTH - 46, 5, 41, 30)]; - [monthPcikerView setFrame:CGRectMake(0, 40, SCREEN_WIDTH, MAIN_HEIGHT-40)]; - }else if (deviceOrientation == UIInterfaceOrientationLandscapeLeft||deviceOrientation==UIInterfaceOrientationLandscapeRight){ - [mainView setFrame:CGRectMake(0, 300-MAIN_HEIGHT, [EUtility screenHeight], MAIN_HEIGHT)]; - [toolView setFrame:CGRectMake(0, 0, [EUtility screenHeight], 40)]; - [toolView.lay setFrame:CGRectMake(0, 0, [EUtility screenHeight], 40)]; - [toolView.confirm setFrame:CGRectMake([EUtility screenHeight] - 46, 5, 41, 30)]; - [toolView.cancle setFrame:CGRectMake(5, 5, 41, 30)]; - [monthPcikerView setFrame:CGRectMake(0, 40, [EUtility screenHeight], MAIN_HEIGHT-40)]; } + } -(void)showMonthPickerWithType:(int)type date:(NSDate *)inDate{ + NSLog(@"DatePicker showMonthPickerWithType start"); if (mainView) { return; } self.pickerType = [NSNumber numberWithInt:type]; - NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:10]; self.selectValue = dict; [dict release]; - [self setResultFormat:inDate]; UIInterfaceOrientation deviceOrientation = [[UIApplication sharedApplication] statusBarOrientation]; - if ([EUtility isIpad] || deviceOrientation == UIInterfaceOrientationPortrait || deviceOrientation == UIInterfaceOrientationPortraitUpsideDown) { - self.mainView = [[[UIView alloc] initWithFrame:CGRectMake(0, [EUtility screenHeight], SCREEN_WIDTH, MAIN_HEIGHT)] autorelease]; - self.toolView = [[[HeaderView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 40)] autorelease]; + if ( deviceOrientation == UIInterfaceOrientationPortrait || deviceOrientation == UIInterfaceOrientationPortraitUpsideDown) { + + int width = [EUtility screenWidth]; + int height =[EUtility screenHeight]; + + int realwidth = MAX(width, height); + int realheight = MIN(width, height); + if (isPad) + { + self.mainView = [[[UIView alloc] initWithFrame:CGRectMake(0,realwidth, realheight, MAIN_HEIGHT)] autorelease]; + }else{ + + self.mainView = [[[UIView alloc] initWithFrame:CGRectMake(0,[EUtility screenHeight]-MAIN_HEIGHT, realheight, MAIN_HEIGHT)] autorelease]; + } + self.mainView = [[[UIView alloc] initWithFrame:CGRectMake(0,realwidth-MAIN_HEIGHT, realheight, MAIN_HEIGHT)] autorelease]; + self.toolView = [[[HeaderView alloc] initWithFrame:CGRectMake(0, 0, realheight, 40)] autorelease]; + self.toolView.confirm.frame = CGRectMake(realheight-65, 5, 41, 30); self.monthPcikerView = [[[CDatePickerViewEx alloc] init] autorelease]; - [monthPcikerView setFrame:CGRectMake(0, 40, SCREEN_WIDTH, MAIN_HEIGHT-40)]; + [monthPcikerView setFrame:CGRectMake(0, 40,realheight, MAIN_HEIGHT-40)]; }else { - self.mainView = [[[UIView alloc] initWithFrame:CGRectMake(0, 300-MAIN_HEIGHT, [EUtility screenHeight], MAIN_HEIGHT)] autorelease]; - self.toolView = [[[HeaderView alloc] initWithFrame:CGRectMake(0, 0,[EUtility screenHeight], 40)] autorelease]; + + int width = [EUtility screenWidth]; + int height =[EUtility screenHeight]; + + int realwidth = MAX(width, height); + int realheight = MIN(width, height); + if (isPad) + { + self.mainView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, realheight, MAIN_HEIGHT)] autorelease]; + }else{ + + self.mainView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, realheight, MAIN_HEIGHT)] autorelease]; + } + + self.mainView.backgroundColor = [UIColor yellowColor]; + self.toolView = [[[HeaderView alloc] initWithFrame:CGRectMake(0, 0,realheight, 40)] autorelease]; + self.toolView.confirm.frame = CGRectMake(realheight-55, 5, 41, 30); self.monthPcikerView = [[[CDatePickerViewEx alloc] init] autorelease]; - [monthPcikerView setFrame:CGRectMake(0, 40, [EUtility screenHeight], MAIN_HEIGHT-40)]; + [monthPcikerView setFrame:CGRectMake(0, 40,realheight, MAIN_HEIGHT-40)]; } toolView.delegate = self; @@ -139,7 +192,12 @@ -(void)showMonthPickerWithType:(int)type date:(NSDate *)inDate{ if (euexObj.meBrwView) { if (![EUtility isIpad] || deviceOrientation == UIInterfaceOrientationPortrait || deviceOrientation == UIInterfaceOrientationPortraitUpsideDown) { [UIView animateWithDuration:0.3 animations:^{ - [mainView setFrame:CGRectMake(0, [EUtility screenHeight]-MAIN_HEIGHT, SCREEN_WIDTH, MAIN_HEIGHT)]; + int width = [EUtility screenWidth]; + int height =[EUtility screenHeight]; + + int realwidth = MAX(width, height); + int realheight = MIN(width, height); + [mainView setFrame:CGRectMake(0, realheight-MAIN_HEIGHT, realheight, MAIN_HEIGHT)]; }]; } [(UIView*)euexObj.meBrwView setUserInteractionEnabled:NO]; @@ -151,15 +209,27 @@ -(void)showMonthPickerWithType:(int)type date:(NSDate *)inDate{ [controller release]; self.popController = popover; [popover release]; + int width = [EUtility screenWidth]; + int height =[EUtility screenHeight]; - [popController setPopoverContentSize:CGSizeMake(SCREEN_WIDTH, MAIN_HEIGHT)]; + int realwidth = MAX(width, height); + int realheight = MIN(width, height); + [popController setPopoverContentSize:CGSizeMake(realheight, MAIN_HEIGHT)]; [popController setDelegate:self]; //让pop窗口的位置在中间 int x = SCREEN_WIDTH/2; int y = (SCREEN_HEIGHT-20)/2; [EUtility brwView:euexObj.meBrwView presentPopover:popController FromRect:CGRectMake(x, y, 10, 10) permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; } - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doRotate) name:UIDeviceOrientationDidChangeNotification object:nil]; + if (isPad) + { + + + }else{ + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doRotate) name:UIDeviceOrientationDidChangeNotification object:nil]; + + } + } @@ -200,6 +270,7 @@ - (void)confirm:(id)headerView{ NSDate *checkDate = monthPcikerView.resultDate; [self setResultFormat:checkDate]; + // NSLog(@"selectValue = %@",[selectValue description]); [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil]; // if ([pickerType intValue]==0) { // [euexObj uexOpenDatePickerWithOpId:0 dataType:UEX_CALLBACK_DATATYPE_JSON data:[selectValue JSONFragment]]; @@ -225,27 +296,28 @@ - (void)confirm:(id)headerView{ } -(void)dealloc{ + NSLog(@"hui--->DatePicker dealloc"); [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil]; if (popController) { - [popController release]; - popController = nil; + NSLog(@"hui--->DatePicker dealloc self.popController retaincount is %d",[self.popController retainCount]); + self.popController = nil; } if (monthPcikerView) { - [monthPcikerView release]; - monthPcikerView = nil; + NSLog(@"hui--->DatePicker dealloc pickerView"); + self.monthPcikerView = nil; } if (toolView) { - toolView.delegate = nil; - [toolView release]; - toolView = nil; + NSLog(@"hui--->DatePicker dealloc toolView"); + self.toolView.delegate = nil; + self.toolView = nil; } if (mainView) { - [mainView release]; - mainView = nil; + NSLog(@"hui--->DatePicker dealloc mainView"); + self.mainView = nil; } if (selectValue) { - [selectValue release]; - selectValue = nil; + NSLog(@"hui--->DatePicker dealloc selectValue"); + self.selectValue = nil; } [super dealloc]; } diff --git a/EUExControl/EUExControl/sourceCode/Public_HIST.h b/EUExControl/EUExControl/sourceCode/Public_HIST.h new file mode 100644 index 0000000..a761063 --- /dev/null +++ b/EUExControl/EUExControl/sourceCode/Public_HIST.h @@ -0,0 +1,19 @@ +// +// Public_HIST.h +// AppCan +// +// Created by asang on 14-7-22. +// +// + +#import + +#define IS_NSString(x) ([x isKindOfClass:[NSString class]] && x.length>0) +#define IS_NSMutableArray(x) ([x isKindOfClass:[NSMutableArray class]] && [x count]>0) +#define IS_NSArray(x) ([x isKindOfClass:[NSArray class]] && [x count]>0) +#define IS_NSMutableDictionary(x) ([x isKindOfClass:[NSMutableDictionary class]]) +#define IS_NSDictionary(x) ([x isKindOfClass:[NSDictionary class]]) + +@interface Public_HIST : NSObject ++(UIColor *)strToColor:(NSString *)str; +@end diff --git a/EUExControl/EUExControl/sourceCode/Public_HIST.m b/EUExControl/EUExControl/sourceCode/Public_HIST.m new file mode 100644 index 0000000..559f4b1 --- /dev/null +++ b/EUExControl/EUExControl/sourceCode/Public_HIST.m @@ -0,0 +1,26 @@ +// +// Public_HIST.m +// AppCan +// +// Created by asang on 14-7-22. +// +// + +#import "Public_HIST.h" +#import "EUtility.h" + +@implementation Public_HIST + +#pragma mark - +#pragma mark NSString转换为UIColor + ++(UIColor *)strToColor:(NSString *)str{ + if ([str isKindOfClass:[NSString class]] && str.length>0) { + UIColor *colors = [EUtility ColorFromString:str]; + return colors; + }else{ + return nil; + } +} + +@end diff --git a/EUExControl/uexControl/libuexControl.a b/EUExControl/uexControl/libuexControl.a index 82614d7..6500ab8 100644 Binary files a/EUExControl/uexControl/libuexControl.a and b/EUExControl/uexControl/libuexControl.a differ