Commit bcdb81c9 authored by 曹云霄's avatar 曹云霄

优化代码

parent 634825aa
......@@ -43,11 +43,10 @@
MWPhoto *photo = [MWPhoto photoWithURL:[NSURL URLWithString:att.fileUrl]];
[self.browserArray addObject:photo];
}
#warning 待修改
MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
[browser setCurrentPhotoIndex:tap.view.tag];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:browser];
// [self.viewController.navigationController presentViewController:nav animated:YES completion:nil];
[self.viewController.navigationController presentViewController:nav animated:YES completion:nil];
}
#pragma mark - <MWPhotoBrowserDelegate>
......
......@@ -90,8 +90,7 @@ typedef NS_ENUM(NSInteger, ItemIndex) {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
[camera setSourceType:UIImagePickerControllerSourceTypeCamera];
camera.allowsEditing = YES;
#warning 待修改
// [self.viewController presentViewController:camera animated:YES completion:nil];
[self.viewController presentViewController:camera animated:YES completion:nil];
} else {
[XBLoadingView showHUDViewWithText:@"相机无法使用"];
}
......@@ -196,32 +195,23 @@ typedef NS_ENUM(NSInteger, ItemIndex) {
}
- (void)selectAlbumImage {
if (![BaseViewController determinePhotosPermissions]) {
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"提示" message:@"请在iPad的“设置-隐私-相册”选项中,允许欧立方访问你的相册" preferredStyle:UIAlertControllerStyleAlert];
[alertVC addAction:[UIAlertAction actionWithTitle:@"知道了" style:UIAlertActionStyleCancel handler:nil]];
#warning 待修改
// [self.viewController presentViewController:alertVC animated:YES completion:nil];
return;
if ([BaseViewController determinePhotosPermissions]) {
MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
browser.displayActionButton = YES;
browser.displayNavArrows = YES;
browser.displaySelectionButtons = YES;
browser.alwaysShowControls = YES;
browser.zoomPhotosToFill = YES;
browser.enableGrid = YES;
browser.startOnGrid = YES;
browser.enableSwipeToDismiss = YES;
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:browser];
[self.viewController.navigationController presentViewController:nav animated:YES completion:nil];
}
MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
browser.displayActionButton = YES;
browser.displayNavArrows = YES;
browser.displaySelectionButtons = YES;
browser.alwaysShowControls = YES;
browser.zoomPhotosToFill = YES;
browser.enableGrid = YES;
browser.startOnGrid = YES;
browser.enableSwipeToDismiss = YES;
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:browser];
#warning 待修改
// [self.viewController.navigationController presentViewController:nav animated:YES completion:nil];
}
- (void)deletePhotoWithIndex:(NSInteger)index {
UIImage *image = self.arrSelectedPhotos[index];
//如果要删除的照片在缓存里面,那么这是相册选择的照片,需要从缓存删除
for (PHAsset *key in self.cache.allKeys) {
UIImage *cacheImage = [self.cache objectForKey:key];
......@@ -231,7 +221,6 @@ typedef NS_ENUM(NSInteger, ItemIndex) {
break;
}
}
[self.arrSelectedPhotos removeObject:image];
......
......@@ -38,9 +38,6 @@
- (IBAction)actionStartAnswer:(id)sender {
AssessmentViewController *assessmentVc = [[AssessmentViewController getLearningCenterStoryboardClass] instantiateViewControllerWithIdentifier:@"AssessmentViewController"];
assessmentVc.taskId = _model.fid;
// assessmentVc.indexPath = indexPath;
// assessmentVc.delegate = weakSelf;
#warning 待修改
// [self.viewController.navigationController pushViewController:assessmentVc animated:YES];
[self.viewController.navigationController pushViewController:assessmentVc animated:YES];
}
@end
......@@ -47,9 +47,6 @@
- (IBAction)actionStartAnswer:(id)sender {
AssessmentViewController *assessmentVc = [[AssessmentViewController getLearningCenterStoryboardClass] instantiateViewControllerWithIdentifier:@"AssessmentViewController"];
assessmentVc.taskId = _model.fid;
// assessmentVc.indexPath = indexPath;
// assessmentVc.delegate = weakSelf;
#warning 待修改
// [self.viewController.navigationController pushViewController:assessmentVc animated:YES];
[self.viewController.navigationController pushViewController:assessmentVc animated:YES];
}
@end
......@@ -160,9 +160,8 @@
LoginInfo *login = [[LoginInfo alloc]init];
login.username = self.userName.text;
login.password = self.passWord.text;
#warning 待修改
// login.username = [login.username formatString];
// login.password = [login.password formatString];
login.username = [login.username formatString];
login.password = [login.password formatString];
WS(weakSelf);
[HTTP networkRequestWithURL:SERVERREQUESTURL(LOGIN) withRequestType:ZERO withParameter:login withReturnValueBlock:^(id returnValue) {
[XBLoadingView hideHUDViewWithDefault];
......@@ -286,11 +285,10 @@
[XBLoadingView showHUDViewWithText:@"手机号不能为空"];
return;
}
#warning 待修改
// if (![HENLENSONG isValidateMobile:inputPhoneNumber]) {
// [XBLoadingView showHUDViewWithText:@"手机号码格式不正确"];
// return;
// }
if (![inputPhoneNumber isTelephone]) {
[XBLoadingView showHUDViewWithText:@"手机号码格式不正确"];
return;
}
[XBLoadingView showHUDViewWithDefault];
NSString *urlString = [NSString stringWithFormat:SERVERREQUESTURL(SENDSMS),inputPhoneNumber,self.identityView.userName.text];
[HTTP networkWithDictionaryRequestWithURL:[self returnUrlString:urlString] withRequestType:ONE withParameter:nil withReturnValueBlock:^(id returnValue) {
......
......@@ -568,12 +568,11 @@
[XBLoadingView showHUDViewWithText:@"手机号码不能为空"];
return;
}
#warning 待修改
// NSString *phoneNumber = self.phoneNumberField.text;
// if (![HENLENSONG isValidateMobile:phoneNumber]) {
// [XBLoadingView showHUDViewWithText:@"手机号码格式不正确"];
// return;
// }
NSString *phoneNumber = self.phoneNumberField.text;
if (![phoneNumber isTelephone]) {
[XBLoadingView showHUDViewWithText:@"手机号码格式不正确"];
return;
}
if ([BaseViewController isBlankString:self.customerAddress.text]) {
[XBLoadingView showHUDViewWithText:@"地址不能为空"];
return;
......
......@@ -167,10 +167,9 @@
if ([Shoppersmanager manager].shoppers.employee.isComplete) {
[self dismissViewControllerAnimated:YES completion:nil];return;
}
#warning 待修改
// if (![HENLENSONG isValidateMobile:self.informationArray[1][3]]) {
// [XBLoadingView showHUDViewWithText:@"手机号码格式不正确"];return;
// }
if (![self.informationArray[1][3] isTelephone]) {
[XBLoadingView showHUDViewWithText:@"手机号码格式不正确"];return;
}
WS(weakSelf);
[XBLoadingView showHUDViewWithDefault];
RsEmployeeRequest *employ = [[RsEmployeeRequest alloc]init];
......
......@@ -92,11 +92,10 @@
[XBLoadingView showHUDViewWithText:@"手机号码不能为空"];
return;
}
#warning 待修改
// if (![HENLENSONG isValidateMobile:phoneNumber]) {
// [XBLoadingView showHUDViewWithText:@"手机号码格式不正确"];
// return;
// }
if (![phoneNumber isTelephone]) {
[XBLoadingView showHUDViewWithText:@"手机号码格式不正确"];
return;
}
if ([BaseViewController isBlankString:self.detailsAddress.text]) {
[XBLoadingView showHUDViewWithText:@"请输入详细地址"];
return;
......
......@@ -90,10 +90,9 @@
if ([[self class] isBlankString:self.mobileTextField.text]) {
[XBLoadingView showHUDViewWithText:@"联系电话不能为空"];return;
}
#warning 待修改
// if (![HENLENSONG isValidateMobile:self.mobileTextField.text]) {
// [XBLoadingView showHUDViewWithText:@"手机号码格式不正确"];return;
// }
if (![self.mobileTextField.text isTelephone]) {
[XBLoadingView showHUDViewWithText:@"手机号码格式不正确"];return;
}
if ([[self class] isBlankString:self.addressButton.currentTitle]) {
[XBLoadingView showHUDViewWithText:@"地址不能为空"];return;
}
......
......@@ -85,10 +85,9 @@
if ([self isPureInt:entity.accountName]) {
[XBLoadingView showHUDViewWithText:@"银行卡号格式不正确"]; return;
}
#warning 待修改
// if (![HENLENSONG isValidateMobile:entity.phoneNumber]) {
// [XBLoadingView showHUDViewWithText:@"手机号码格式不正确"]; return;
// }
if (![entity.phoneNumber isTelephone]) {
[XBLoadingView showHUDViewWithText:@"手机号码格式不正确"]; return;
}
NSString *type = [MyBankClass returnBankName:entity.bankAccount];
WS(weakSelf);
[XBLoadingView showHUDViewWithDefault];
......
......@@ -13,6 +13,7 @@
#import "MMDrawerController.h"
#import "RightViewController.h"
#import "IQKeyboardManager.h"
#import "IQUIView+Hierarchy.h"
#import "AFNetworking.h"
#import "NetworkRequestClassManager.h"
#import "ShoppingViewController.h"
......
......@@ -199,7 +199,7 @@
PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatus];
if (status == PHAuthorizationStatusRestricted ||
status == PHAuthorizationStatusDenied) {
//无权限
ShowAlertView(@"提示", @"请在iPad的“设置-隐私-相册”选项中,允许欧立方访问你的相册", @[@"我知道了"], UIAlertControllerStyleAlert, nil);
return NO;
}
return YES;
......@@ -541,29 +541,6 @@
return NO;
}
/**
选择框
@param message 文本
@param cancel 取消
@param sure 确认
*/
- (void)promptBoxWithMessage:(NSString *)message cancelBlock:(void(^)())cancel sureBlock:(void(^)())sure
{
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"提示" message:message preferredStyle:UIAlertControllerStyleAlert];
[alertVC addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
if (cancel) {
cancel();
}
}]];
[alertVC addAction:[UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
if (sure) {
sure();
}
}]];
[self presentViewController:alertVC animated:YES completion:nil];
}
/**
闯关结果状态
......
......@@ -62,7 +62,7 @@ PODS:
- WYPopoverController (0.3.9)
- WZLBadge (1.2.6)
- YXAlertController (1.0.7)
- YXKit (0.0.1)
- YXKit (0.0.2)
DEPENDENCIES:
- AFNetworking (~> 3.1.0)
......@@ -88,7 +88,7 @@ DEPENDENCIES:
- WYPopoverController (~> 0.3.9)
- WZLBadge (~> 1.2.5)
- YXAlertController (~> 1.0.7)
- YXKit (~> 0.0.1)
- YXKit (~> 0.0.2)
SPEC CHECKSUMS:
AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67
......@@ -116,8 +116,8 @@ SPEC CHECKSUMS:
WYPopoverController: a9db25ac2841a686acdc0f3a99bdb21545db32f4
WZLBadge: 9ec779dcfd94c825518b395e8315fccaabff1bfa
YXAlertController: 68e27c48976fa9ecc0b82e63166b67863be8b70b
YXKit: c43af7c4c72f5a3f4e6b59e4eca6946f1859f478
YXKit: 4869008392fd3ee0290ccc4dd657859b8a2e5939
PODFILE CHECKSUM: 663d88b7300774a48ecbbca414ddc8052abf95f2
PODFILE CHECKSUM: fba6b1ce033e4e3eb9e7890a823bc096661655fa
COCOAPODS: 1.2.1
......@@ -62,7 +62,7 @@ PODS:
- WYPopoverController (0.3.9)
- WZLBadge (1.2.6)
- YXAlertController (1.0.7)
- YXKit (0.0.1)
- YXKit (0.0.2)
DEPENDENCIES:
- AFNetworking (~> 3.1.0)
......@@ -88,7 +88,7 @@ DEPENDENCIES:
- WYPopoverController (~> 0.3.9)
- WZLBadge (~> 1.2.5)
- YXAlertController (~> 1.0.7)
- YXKit (~> 0.0.1)
- YXKit (~> 0.0.2)
SPEC CHECKSUMS:
AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67
......@@ -116,8 +116,8 @@ SPEC CHECKSUMS:
WYPopoverController: a9db25ac2841a686acdc0f3a99bdb21545db32f4
WZLBadge: 9ec779dcfd94c825518b395e8315fccaabff1bfa
YXAlertController: 68e27c48976fa9ecc0b82e63166b67863be8b70b
YXKit: c43af7c4c72f5a3f4e6b59e4eca6946f1859f478
YXKit: 4869008392fd3ee0290ccc4dd657859b8a2e5939
PODFILE CHECKSUM: 663d88b7300774a48ecbbca414ddc8052abf95f2
PODFILE CHECKSUM: fba6b1ce033e4e3eb9e7890a823bc096661655fa
COCOAPODS: 1.2.1
This diff is collapsed.
......@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.0.1</string>
<string>0.0.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
......
......@@ -3,6 +3,6 @@
![](https://img.shields.io/badge/language-OC/Swift-orange.svg)
![](https://img.shields.io/badge/QQ-1105938518-orange.svg)
pod 'YXKit', '~>1.0.0'
pod 'YXKit', '~>0.0.1'
......@@ -11,6 +11,7 @@
@interface NSString (Category)
/**
* 判断字符串是否为空
*/
......@@ -153,7 +154,10 @@
*/
- (NSString*)sha512;
/**
格式化字符串
*/
- (NSString *)formatString;
@end
......
......@@ -514,4 +514,15 @@
}
/**
去掉前后空格
*/
- (NSString *)formatString
{
NSCharacterSet *set = [NSCharacterSet whitespaceAndNewlineCharacterSet];
NSString *string = [self stringByTrimmingCharactersInSet:set];
return string;
}
@end
......@@ -26,6 +26,18 @@
//文字居中,图片在右边
- (void)horizontalCenterTitleAndImageRight:(CGFloat)spacing;
/**
* 倒计时按钮
*
* @param timeLine 倒计时总时间
* @param title 还没倒计时的title
* @param subTitle 倒计时中的子名字,如时、分
* @param mColor 还没倒计时的颜色
* @param color 倒计时中的颜色
*/
- (void)startWithTime:(NSInteger)timeLine title:(NSString *)title countDownTitle:(NSString *)subTitle mainColor:(UIColor *)mColor countColor:(UIColor *)color;
/**
快速创建按钮
......
......@@ -27,6 +27,41 @@ NSString const *UIButton_badgeValueKey = @"UIButton_badgeValueKey";
@implementation UIButton (Category)
- (void)startWithTime:(NSInteger)timeLine title:(NSString *)title countDownTitle:(NSString *)subTitle mainColor:(UIColor *)mColor countColor:(UIColor *)color {
__weak typeof(self) weakSelf = self;
//倒计时时间
__block NSInteger timeOut = timeLine;
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_source_t _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
//每秒执行一次
dispatch_source_set_timer(_timer, dispatch_walltime(NULL, 0), 1.0 * NSEC_PER_SEC, 0);
dispatch_source_set_event_handler(_timer, ^{
//倒计时结束,关闭
if (timeOut <= 0) {
dispatch_source_cancel(_timer);
dispatch_async(dispatch_get_main_queue(), ^{
weakSelf.backgroundColor = mColor;
[weakSelf setTitle:title forState:UIControlStateNormal];
weakSelf.userInteractionEnabled = YES;
});
} else {
int allTime = (int)timeLine + 1;
int seconds = timeOut % allTime;
NSString *timeStr = [NSString stringWithFormat:@"%0.2d", seconds];
dispatch_async(dispatch_get_main_queue(), ^{
weakSelf.backgroundColor = color;
[weakSelf setTitle:[NSString stringWithFormat:@"%@%@",timeStr,subTitle] forState:UIControlStateNormal];
weakSelf.userInteractionEnabled = NO;
});
timeOut--;
}
});
dispatch_resume(_timer);
}
/**
快速创建按钮
*/
......
......@@ -27,6 +27,6 @@ target 'Lighting' do
pod 'iCarousel', '~> 1.8.3'
pod 'UMengAnalytics'
pod 'Bugly', '~> 2.4.7'
pod 'YXKit, ~> 0.0.1
pod 'YXKit, ~> 0.0.2
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment