Skip to content

Commit

Permalink
Fxed the issue that customize keyboard accessory is inoperative until…
Browse files Browse the repository at this point in the history
… the app is relaunched.
  • Loading branch information
lm2343635 committed Aug 18, 2017
1 parent 8ff0ab5 commit 7737a68
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Httper.xcodeproj/project.pbxproj
Expand Up @@ -568,7 +568,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
Expand Down
2 changes: 1 addition & 1 deletion Httper/Info.plist
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.2</string>
<string>2.2.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand Down
7 changes: 6 additions & 1 deletion Httper/RequestBodyViewController.swift
Expand Up @@ -11,7 +11,7 @@ import MGKeyboardAccessory

class RequestBodyViewController: UIViewController {

let characters = UserManager.sharedInstance.characters!
var characters: [String]!

var body: String!

Expand All @@ -20,11 +20,16 @@ class RequestBodyViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
rawBodyTextView.text = body
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(true)
rawBodyTextView.setupKeyboardAccessory(characters, barStyle: .black)
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(true)
characters = UserManager.sharedInstance.characters!
rawBodyTextView.becomeFirstResponder()
}

Expand Down
19 changes: 15 additions & 4 deletions Httper/RequestViewController.swift
Expand Up @@ -25,7 +25,8 @@ class RequestViewController: UIViewController, UITableViewDelegate, UITableViewD
var editingTextField: UITextField!

let dao = DaoManager.sharedInstance
let characters = UserManager.sharedInstance.characters!
// Customized characters of keyboard accessory.
var characters: [String]!

var headerCount = 1, parameterCount = 1
var method: String = "GET"
Expand All @@ -51,19 +52,29 @@ class RequestViewController: UIViewController, UITableViewDelegate, UITableViewD
sendButton.layer.borderColor = UIColor.lightGray.cgColor
saveButton.layer.borderColor = UIColor.lightGray.cgColor

urlTextField.setupKeyboardAccessory(characters, barStyle: .black)

NotificationCenter.default.addObserver(self, selector: #selector(bodyChanged(notification:)), name: NSNotification.Name(rawValue: "bodyChanged"), object: nil)
}

override func viewDidAppear(_ animated: Bool) {
super.viewWillDisappear(animated)

}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

characters = UserManager.sharedInstance.characters!
// Setup keyboard accessory.
urlTextField.setupKeyboardAccessory(characters, barStyle: .black)
for cell in valueTableView.visibleCells {
if cell.reuseIdentifier == "headerIdentifier" || cell.reuseIdentifier == "parameterIdentifier" {
let keyTextField = cell.viewWithTag(1) as! UITextField
let valueTextField = cell.viewWithTag(2) as! UITextField
keyTextField.setupKeyboardAccessory(characters, barStyle: .black)
valueTextField.setupKeyboardAccessory(characters, barStyle: .black)
}
}

// Set request method.
requestMethodButton.setTitle(method, for: .normal)

Expand Down

0 comments on commit 7737a68

Please sign in to comment.