Commit 8877ee65 authored by Adam Procter's avatar Adam Procter Committed by Adam Procter

saving is now using the UI toolbar button on keyboard , much faster

parent f6673910
......@@ -28,35 +28,14 @@
<fontDescription key="fontDescription" type="system" pointSize="42"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
</textView>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Efi-fm-5QU">
<rect key="frame" x="103" y="37" width="169" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="22"/>
<state key="normal" title="Save Thought"/>
<connections>
<action selector="buttonTap:" destination="BYZ-38-t0r" eventType="touchUpInside" id="fz6-uX-isR"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
<connections>
<outlet property="reminderText" destination="5oo-TQ-2cm" id="gcV-jo-OZx"/>
<outlet property="toolbar" destination="sZN-cC-Hlp" id="QFZ-OD-o9s"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
<toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="xVN-ZI-E6g">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<items>
<barButtonItem systemItem="done" id="sZN-cC-Hlp">
<connections>
<action selector="DoneTap:" destination="BYZ-38-t0r" id="kjG-v8-YM5"/>
</connections>
</barButtonItem>
</items>
</toolbar>
</objects>
<point key="canvasLocation" x="125.59999999999999" y="38.23088455772114"/>
</scene>
......
......@@ -14,26 +14,12 @@ class ViewController: UIViewController {
// setting the EventKit Vars ready for use
var eventStore = EKEventStore()
var calendars:Array<EKCalendar> = []
@IBOutlet weak var reminderText: UITextView!
@IBOutlet weak var toolbar: UIBarButtonItem!
// reminderText.maximumNumberOfLines = 5;
// the input field
@IBAction func DoneTap(_ sender: Any) {
view.endEditing(true)
}
//button
@IBAction func buttonTap(_ sender: Any) {
setReminder()
}
func setReminder(){
// storing the data into the store
......@@ -78,12 +64,34 @@ view.endEditing(true)
// print("Calendar = \(calendar.title)")
// }
//
//init toolbar
let toolbar:UIToolbar = UIToolbar(frame: CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: 30))
//create left side empty space so that done button set on right side
let flexSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
let doneBtn: UIBarButtonItem = UIBarButtonItem(title: "Save", style: .done, target: self, action: #selector(ViewController.setReminder))
//array of BarButtonItems
var arr = [UIBarButtonItem]()
arr.append(flexSpace)
arr.append(doneBtn)
toolbar.setItems(arr, animated: false)
toolbar.sizeToFit()
//setting toolbar as inputAccessoryView
self.reminderText.inputAccessoryView = toolbar
}
func textViewShouldBeginEditing(_ textView: UITextView){
// textView.inputAccessoryView = toolbar
// textView.inputAccessoryView = toolbar
}
......
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