• Stars
    star
    262
  • Rank 156,136 (Top 4 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created about 11 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ARAutocompleteTextView is a subclass of UITextView that automatically displays text suggestions in real-time. This is perfect for automatically suggesting the domain as a user types an email address, #hashtag or @alexruperez.

ARAutocompleteTextView

Twitter GitHub Issues Version Status License Status Platform Status Analytics

Overview

ARAutocompleteTextView is a subclass of UITextView that automatically displays text suggestions in real-time. This is perfect for automatically suggesting the domain as a user types an email address, #hashtag or @handle.

ARTextViewAutocompletion

Usage

Installation

Add the following files to your project:

  • ARAutocompleteTextView.m
  • ARAutocompleteTextView.h
  • ARAutocompleteManager.m
  • ARAutocompleteManager.h

Quickstart Guide

Create an ARAutocompleteTextView instance exactly as as you would UITextView. You can do eith either programmitcally or in Interface Builder. Programmatically, this looks like:

Objective C
ARAutocompleteTextView* textField = [[ARAutocompleteTextView alloc] initWithFrame:CGRectMake(0,0,100,31)];
Swift
let textField = ARAutocompleteTextView(frame: CGRectMake(0, 0, 100, 31))

The data source is the brains of the autocomplete logic. If you just want to autocomplete email addresses, #hashtags or @handles, use ARAutocompleteManager from the example project as follows:

Objective-C
textField.autocompleteDataSource = [ARAutocompleteManager sharedManager];
textField.autocompleteType = ARAutocompleteTypeEmail;
Swift
textField.autocompleteDataSource = ARAutocompleteManager.sharedManager()
textField.autocompleteType = ARAutocompleteType.Mail

Customization

Autocompletion Data Source

ARAutocompleteManager (included in the example project) provides email address autocompletion out of the box. It comes with a list of the top email domains. You may want to tailor this list of email domains to match your own customers, or you may want to write autocomplete logic for a different type of text view (in the demo, names of colors are autocompleted).

Alternatively, you may wish to create your own data source class and user the autocompleteType property to differentiate between textviews with different data types. A ARAutocompleteTextView's data source must implement the following method, as part of the ARAutocompleteDataSource protocol.

- (NSString *)textField:(ARAutocompleteTextView*)textField completionForPrefix:(NSString *)prefix

You may also set a default dataSource for all instances of ARAutocompleteTextView. In the example project, we use a ARAutocompleteManager singleton:

 [autocompleteTextOffset setDefaultAutocompleteDataSource:[ARAutocompleteManager sharedManager]];

Positioning and Formatting

To adjust the position of the autocomplete label by a fixed amount, set autocompleteTextOffset:

textField.autocompleteTextOffset = CGPointMake(10.0, 10.0);

For more dynamic positioning of the autocomplete label, subclass ARAutocompleteTextView and override - (CGRect)autocompleteRectForBounds:(CGRect)bounds.

To adjust the properties (i.e. font, textColor) of the autocomplete label, do so via the `[AutocompleteTextField autocompleteLabel] property.

textField.autocompleteLabel.textColor = [UIColor grayColor];

Event Listening

In addition to observing the standard UITextView notifications (i.e. UITextViewTextDidChangeNotification and friends), you can use [ARAutocompleteTextView autoCompleteTextFieldDelegate] to listen for certain events. This is particularly useful if you are collecting analytics.

Etc.

  • Use this in your apps whenever you can, particularly email addresses -- your users will appreciate it!
  • Contributions are very welcome.
  • Attribution is appreciated (let's spread the word!), but not mandatory.

Use it? Love/hate it?

Tweet the author @alexruperez, and check out alexruperez's blog: http://alexruperez.com

Other Links

code4app Review

Cocoa Controls

More Repositories

1

SecurePropertyStorage

Helps you define secure storages for your properties using Swift property wrappers.
Swift
473
star
2

UIUserNotificationSettings-Extension

Helper methods that will make you much easier to handle #Interactive #Notifications.
Objective-C
272
star
3

LaunchScreenSnapshot

Protects sensitive data in your app snapshot.
Swift
206
star
4

SpeechRecognizerButton

UIButton subclass with push to talk recording, speech recognition and Siri-style waveform view.
Swift
163
star
5

UILabel-AutomaticWriting

UILabel category with automatic writing (type out) animation.
Objective-C
158
star
6

Tagging

🏷 Type-safe tags in Swift
Swift
91
star
7

ARHomeScreenShortcuts

Installs home screen shortcuts to features of your app.
Objective-C
79
star
8

ARDetector

CIDetector, AVCaptureVideoDataOutput and AVCaptureMetadataOutput categories. With face, rectangle, QR Code and TEXT CIDetector and blocks for AVCaptureOutput handling.
Objective-C
71
star
9

ARSafariActivity

A UIActivity subclass that opens URLs in Safari
Objective-C
55
star
10

NSDate-Extension

Use NSDate-Extension to handle NSDate objects easily. Syntactic sugar. #DSL Style
Objective-C
48
star
11

StateMachine

State machine creation framework written in Swift inspired by GKStateMachine from Apple GameplayKit
Swift
48
star
12

FSNetworkingSearchController

Search controller with suggest completion using Foursquare API following Instagram design.
Objective-C
46
star
13

ARWebServerActivity

A UIActivity subclass that share files via GCDWebServer with Twitter Bootstrap UI.
Objective-C
40
star
14

AVPlayerItemHomeOutput

Coordinate the output of content associated with your HomeKit lightbulbs. #Ambilight
Swift
37
star
15

ARObjectCollectionViewController

UIViewController that can present a JSON NSString, JSON NSData, JSON URL, XML NSData, XML URL, RSS NSData, RSS URL, NSDictionary, NSArray, NSSet, UIImage EXIF Metadata...
Objective-C
34
star
16

PFLinkedInUtils

The #PFLinkedInUtils class provides utility functions for working with #LinkedIn in a #Parse application.
Objective-C
31
star
17

ARDeepLinkButton

#UIButton subclass that handle deep links, shows in-app #SKStoreProductViewController or redirects to the #AppStore. Written in #Swift 2.1.1
Swift
26
star
18

ARSpeechActivity

ARSpeechActivity is a UIActivity subclass that uses AVSpeechUtterance to read aloud the shared NSString
Objective-C
25
star
19

ARAutocompleteSearchBar

ARAutocompleteSearchBar is a subclass of UISearchBar that automatically displays text suggestions in real-time.
Objective-C
23
star
20

ARFacebookShareKitActivity

Launch FBSDKShareKit from UIActivityViewController instead of the default Facebook share sheet.
Objective-C
23
star
21

MADBike

This is the public repository of the MADBike app for iOS. Public bike rental service for BiciMAD.
Objective-C
23
star
22

ARAlertController

UIAlertController compatible iOS >= 5.0
Objective-C
22
star
23

SafeBrowsing

Protect your users against malware and phishing threats using Google Safe Browsing
Swift
20
star
24

iOS-Coding-Best-Practices

iOS Coding Best Practices
Objective-C
16
star
25

NSDictionary-Verified

NSDictionary+Verified checks NSNull (aka kCFNull) objects and it changes to nil
Objective-C
11
star
26

OpenMarvel

Open source iOS application for searching Marvel characters.
Swift
5
star
27

ARButtonBlock

UIButton subclass with touchUpInside as block helper.
Objective-C
4
star
28

ImageFromWebView

Captures an image of a UIWebView, makes an UIImage, shows on an UIImageView and saves it into the gallery.
Objective-C
4
star
29

swift-library-template

Swift Library Template, just run ./generate.sh
Swift
3
star
30

Tasks

Very useful and complete tutorial explaining how to integrate SiriKit in your apps.
Swift
3
star
31

ARFontsMobileconfigGenerator

Ruby script that generates a mobileconfig file for each folder with fonts that can be installed on any iOS / OS X and use those fonts in apps like Pages, Numbers, Keynote...
Ruby
3
star
32

swift-executable-template

Swift Executable Template, just run ./generate.sh
Swift
2
star
33

Coverflow

Coverflow Implementation using PSTCollectionView (iOS5 supported UICollectionView)
Objective-C
1
star
34

CryptoKitCLI

Take Apple CryptoKit to the command line and perform cryptographic operations securely and efficiently.
Swift
1
star
35

alexruperez-android-app

This is a very simple app, that uses a webview to display http://alexruperez.com on your Android device.
Java
1
star
36

ARFormTextField

UITextField subclass with doneBlock and nextTextField helpers for easier forms creation
Objective-C
1
star