From 976cfc883ad5602ff9983df79c91114c591e4caf Mon Sep 17 00:00:00 2001 From: kevinzhow Date: Sun, 12 Jul 2015 18:31:10 +0800 Subject: [PATCH] Faster pick image and Debug optimization --- Yep.xcodeproj/project.pbxproj | 8 ++--- Yep/Services/YepService.swift | 2 ++ .../ConversationViewController.swift | 34 +++++++++++-------- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/Yep.xcodeproj/project.pbxproj b/Yep.xcodeproj/project.pbxproj index 0a42504d..7e7c621a 100644 --- a/Yep.xcodeproj/project.pbxproj +++ b/Yep.xcodeproj/project.pbxproj @@ -1914,9 +1914,9 @@ GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; + GCC_OPTIMIZATION_LEVEL = 3; GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", + "DEBUG=0", "$(inherited)", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; @@ -1984,7 +1984,7 @@ "$(PROJECT_DIR)/build/Debug-iphoneos/Pods", "$(PROJECT_DIR)", ); - GCC_OPTIMIZATION_LEVEL = 0; + GCC_OPTIMIZATION_LEVEL = 3; INFOPLIST_FILE = Yep/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -2011,7 +2011,7 @@ "$(PROJECT_DIR)/build/Debug-iphoneos/Pods", "$(PROJECT_DIR)", ); - GCC_OPTIMIZATION_LEVEL = 3; + GCC_OPTIMIZATION_LEVEL = s; INFOPLIST_FILE = Yep/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; diff --git a/Yep/Services/YepService.swift b/Yep/Services/YepService.swift index aa7ee0c0..b7aeccd3 100644 --- a/Yep/Services/YepService.swift +++ b/Yep/Services/YepService.swift @@ -404,6 +404,8 @@ func sendVerifyCodeOfMobile(mobile: String, withAreaCode areaCode: String, useMe func loginByMobile(mobile: String, withAreaCode areaCode: String, #verifyCode: String, #failureHandler: ((Reason, String?) -> Void)?, #completion: LoginUser -> Void) { + println("User login type is \(YepConfig.clientType())") + let requestParameters: JSONDictionary = [ "mobile": mobile, "phone_code": areaCode, diff --git a/Yep/ViewControllers/Conversation/ConversationViewController.swift b/Yep/ViewControllers/Conversation/ConversationViewController.swift index b9d2d78a..710672ac 100644 --- a/Yep/ViewControllers/Conversation/ConversationViewController.swift +++ b/Yep/ViewControllers/Conversation/ConversationViewController.swift @@ -136,6 +136,8 @@ class ConversationViewController: BaseViewController { }() let messageImagePreferredAspectRatio: CGFloat = 4.0 / 3.0 + + let imagePicker = UIImagePickerController() let chatSectionDateCellIdentifier = "ChatSectionDateCell" let chatStateCellIdentifier = "ChatStateCell" @@ -560,14 +562,15 @@ class ConversationViewController: BaseViewController { let openCameraRoll: ProposerAction = { [weak self] in if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.PhotoLibrary){ - let imagePicker = UIImagePickerController() - imagePicker.delegate = self - imagePicker.sourceType = .PhotoLibrary - imagePicker.mediaTypes = [kUTTypeImage, kUTTypeMovie] - imagePicker.videoQuality = .TypeMedium - imagePicker.allowsEditing = false - - self?.presentViewController(imagePicker, animated: true, completion: nil) + if let weakSelf = self { + weakSelf.imagePicker.delegate = weakSelf + weakSelf.imagePicker.sourceType = .PhotoLibrary + weakSelf.imagePicker.mediaTypes = [kUTTypeImage, kUTTypeMovie] + weakSelf.imagePicker.videoQuality = .TypeMedium + weakSelf.imagePicker.allowsEditing = false + + weakSelf.presentViewController(weakSelf.imagePicker, animated: true, completion: nil) + } } } @@ -581,14 +584,15 @@ class ConversationViewController: BaseViewController { let openCamera: ProposerAction = { [weak self] in if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera) { - let imagePicker = UIImagePickerController() - imagePicker.delegate = self - imagePicker.sourceType = .Camera - imagePicker.mediaTypes = [kUTTypeImage, kUTTypeMovie] - imagePicker.videoQuality = .TypeMedium - imagePicker.allowsEditing = false + if let weakSelf = self { + weakSelf.imagePicker.delegate = weakSelf + weakSelf.imagePicker.sourceType = .Camera + weakSelf.imagePicker.mediaTypes = [kUTTypeImage, kUTTypeMovie] + weakSelf.imagePicker.videoQuality = .TypeMedium + weakSelf.imagePicker.allowsEditing = false - self?.presentViewController(imagePicker, animated: true, completion: nil) + weakSelf.presentViewController(weakSelf.imagePicker, animated: true, completion: nil) + } } }