#UIPasteboard
Explore tagged Tumblr posts
ttwgroup · 5 years ago
Text
Attendant for Zoom: Clipboard Usage
An interesting new feature of iOS 14 is that users are notified when an app accesses the clipboard (UIPasteboard). Already it seems to be revealing some bad actors (whether intentionally bad or not). Hopefully those get shamed out of existence. On the other hand, I’m hoping that productive and smart uses of the clipboard don’t get lost in this.
In our new app Attendant for Zoom we try to do something smart with the clipboard. Tapping a zoom.us link will automatically join you to a meeting in Zoom; we wanted to be able to provide something similar for Attendant. We accomplish this by checking the clipboard when the app launches or is brought back to the foreground. First we check if the clipboard contains text (this is the part that triggers the notification), then we check if we have already “handled” that text (to avoid alerting repeatedly), then we make sure it’s a URL, and more specifically a zoom.us URL. If we pass all of those checks we present the following alert to the user to ask them to join that meeting.
Tumblr media
I want to be very clear that the contents of the clipboard are not stored in any way and we dot not transmit off device. Of course, if you explicitly ask to Join the meeting we do pass that zoom.us URL to the Zoom SDK. The purpose is to add a convenient way to join a meeting.
How will users view this in iOS 14? Will there be a huge backlash to this type of usage? Should we design for this to be a user triggered event, rather than proactively looking at the clipboard? iOS 14 adds some support that could help limit us to only looking at the clipboard if it is probably a web URL, which should greatly reduce the number of times the notification would appear. But is that enough?
We’d love to hear your feedback @thinktapwork​.
0 notes
arthurknopper · 8 years ago
Text
Use Context Menu with Table View Tutorial
A long-press gesture displays a Context Menu, which gives the user the ability to use cut/copy/paste operations on the selected object. By default, the Context Menu is disabled on a Table View. In this tutorial the context menu will be enabled to copy the text of the Table View Cell, this text can then be pasted into a Text Field. This tutorial is made with Xcode 8.1 and built for iOS 10.
Open Xcode and create a new Single View Application
Choose Next. For product name, use IOS10ContextMenuTableViewTutorial and then fill out the Organization Name and Organization Identifier with your customary values. Enter Swift as Language and make sure only iPhone is selected in Devices.
Open The Main.storyboard file and drag a Table View from the Object Library to the top of the main View.  Select the Table View, go to the Attribute Inspector and in the Table View section change the Prototype Cells field to a value of 1
Select the Table View Cell and go to the Attribute Inspector. In the Table View Cell section set the Identifier to "cell".
Select the Table View, select the Pin button on the bottom-right of the storyboard and pin the Table View on the top, left and right. Also select the Height Attribute to give the Table View a fixed height. Select Items of New Constraints at the Update Frames dropdown box. Next, select Add 4 Constraints.
Drag a Text Field from the Object Library and place it right below the Table View. Ctrl and drag from inside the Text Field to the Table View. Hold Down Ctrl and select "Vertical Spacing" and "Center Horizontally".
Select the Text Field, select the Pin button on the bottom-right of the storyboard and pin the Text Field  to the left and right.
The View Controller needs to be the delegate of the Table View. Select the TableView, Ctrl and Drag to the View Controller icon at the top of the main View. Select Datasource. Repeat this step and select delegate.
Repeat this also for the Text Field to make the View Controller the delegate for it. Go to the ViewController.swift file and change the class declaration line to
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate {
Add the following properties
var pasteBoard = UIPasteboard.generalPasteboard() var tableData: [String] = ["dog","cat","fish"]
The pasteBoard property will be used for copy-paste operations and the tableData holds the contents which will be displayed on the Table View Cells. Next, change the Table View delegate methods.
func numberOfSections(in tableView: UITableView) -> Int { return 1 } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return tableData.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) cell.textLabel?.text = tableData[indexPath.row] return cell }
The Table View will be filled with the three values from the TableData array. To enable the Context  Menu the following three delegate methods must be implemented.
func tableView(_ tableView: UITableView, shouldShowMenuForRowAt indexPath: IndexPath) -> Bool { return true } func tableView(_ tableView: UITableView, canPerformAction action: Selector, forRowAt indexPath: IndexPath, withSender sender: Any?) -> Bool { if (action == #selector(UIResponderStandardEditActions.copy(_:))) { return true } return false } func tableView(_ tableView: UITableView, performAction action: Selector, forRowAt indexPath: IndexPath, withSender sender: Any?) { let cell = tableView.cellForRow(at: indexPath) pasteBoard.string = cell!.textLabel?.text }
The tableView:shouldShowMenuForRowAt method must return true to display the Context Menu when a Table View Cell is long-pressed. In the tableView:canPerformAction:forRowAt method only the copy item is displayed. The tableView:performAction:forRowAt:withSender method copies the selected text into the pasteBoard. 
Finally, implement the textFieldShouldReturn method to dismiss the keyboard when pressing enter when in the editing mode in the Text Field.
func textFieldShouldReturn(_ textField: UITextField) -> Bool { self.view.endEditing(true) return false }
Build and Run the project, Long-press a Table View Cell and Select the copy item. Paste the text inside the Text Field.
You can download the source code of the IOS10ContextMenuTableViewTutorial at the ioscreator repository on Github.
0 notes
whiskmobile-blog · 11 years ago
Photo
Tumblr media
CLP+ Copy & Paste Clipboard Manager
Very excited to announce my latest project. CLP+ is a simple, but extremely useful little app.
Install the "Today Widget" in Notification Center, then when you copy text from any app, it will appear in the list.
Just tap any item in the list to copy it back to the clipboard.
Automatically recognizes different types of content. If you copy a phone number, then it can be called directly from the app. If you copy a URL, then just tap the icon to go to the site. If you copy an email address, then just tap the email icon to compose a new email.
Very simple to use, but powerful and customizable too.
I'll write more about the technical aspects of the project - a few interesting techniques were used - but for now, please give it a try!
1 note · View note
arthurknopper · 7 years ago
Text
PasteBoard iOS Tutorial
In iOS the user has the ability to copy and paste text from different sources. To make use of this feature inside an app, the UIPasteBin object can be used. In this tutorial some text will be copied from a Text Field and paste it to an other Text Field. This tutorial is made with Xcode 10 and built for iOS 12.
Open Xcode and create a new Single View App.
For product name, use IOSPasteBinTutorial and then fill out the Organization Name and Organization Identifier with your customary values. Enter Swift as Language and choose Next.
Go to The StoryBoard and Add Two Text Fields and a button to the Storyboard. Give the button a title of "Copy". Select the "Resolve Auto Layout Button the bottom-right corner of Interface Builder and select "Reset to Suggested Constraints".
Give the main View a light-gray background.The Storyboard should look like this.
Select the Assistant Editor and make sure the ViewController.swift is visible. Ctrl and drag from the first Text Field to the ViewController class  and create the following Outlet.
Repeat this step for the second Text Field.
Ctrl and drag from the Button to the View Controller class and create the following Action
When the user clicks the Text Field the keyboard is presented. To dismiss the keyboard our ViewController must conform to the UITextFieldDelegate protocol. Change the class declaration line to
class ViewController: UIViewController, UITextFieldDelegate {
Change the viewDidLoad method to
override func viewDidLoad() { super.viewDidLoad() fromTextField.delegate = self toTextField.delegate = self }
The View Controller is the delegate of the UITextFieldDeleGate. We need to implement the textFieldShouldReturn method
func textFieldShouldReturn(_ textField: UITextField) -> Bool { textField.resignFirstResponder() return false }
When the Return key is pressed the Keyboard is dismissed. Next, implement the copyText method
@IBAction func copyText(_ sender: Any) { let copyString = fromTextField.text let pasteBoard = UIPasteboard.general pasteBoard.string = copyString }
The text from the First Textfield is assigned to a String. Next, a UIPasteBoard object is initialised with a general PasteBoard. The text from the string is then assigned to the string property of the UIPasteBoard class. Build and Run the project, enter some text in the first Text Field, select Copy and then paste it into the second Text Field.
You can download the source code of the IOSPasteBinTutorial at the ioscreator repository on github.
0 notes