@eddyborja
Keyboard cowboy. Hackernews reader. Vim user. You know the type.
UITextfield subclass with autocomplete menu. For iOS.
License: Other
Sorry, I might be missing something very obvious, but is there a way to tell if the tableview is currently expanded?
I tried subclassing and putting a setter on autoCompleteTableViewHidden but that's not it.
I need to change my layout whenever the table is open.
Thanks in advance!
I use cocoapod and added all your files per instruction.
Yet when I run the app I get Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString asciiLevenshteinDistanceWithString:]: unrecognized selector sent to instance 0x9d5bb40'
Any idea?
Not sure if this is the right place to put it as it's already in the readme, but do you have plans to add String Hiding anytime soon?
Btw thanks for this awesome pod!
My issue is this, i can't touch the suggestion table view cells outside the frame of the navigation bar view, i try to alter the code in the library but the results are the same, i see the reports about the control fixed in some other issues like using the control in a tableview, the problem here is similar because the control is inside a navigation bar item using storyboard, i think is because the view of the tableview is taking all the touch events apart of the touch events inside the navigation top bar frames.
What can i do to fix this issue, i can bring more information of the proyect if you want. Thanks for this amazing library. Sorry for my bad english.
When I Archive my project, Xcode 5.1.1 shows 2 compiler warnings for unused variables.
There are several ways to solve this, see for example:
http://stackoverflow.com/questions/5451123/how-can-i-get-rid-of-an-unused-variable-warning-in-xcode
I have chosen to use:
__unused
MLPAutoCompleteTextField/MLPAutoCompleteTextField.m:600:10: Unused variable 'classSettingSupported'
MLPAutoCompleteTextField/MLPAutoCompleteTextField.m:919:23: Unused variable 'firstObject'
I'm studying iOS programming and I am implementing MLPAutoCompleteTextField to my simple app. I followed instructions and also referred to the sample project. But when I build & run my project, it is successfully compiled but the suggestions are not displayed.
Here's how it looks:http://d.pr/i/Uv3D
AddQuoteViewController.h
#import <UIKit/UIKit.h>
#import "MLPAutoCompleteTextFieldDataSource.h"
#import "MLPAutoCompleteTextFieldDelegate.h"
@class MLPAutoCompleteTextField;
@interface AddQuoteViewController : UIViewController <UITextFieldDelegate, MLPAutoCompleteTextFieldDataSource, MLPAutoCompleteTextFieldDelegate>
@property (strong, nonatomic) IBOutlet MLPAutoCompleteTextField *authorTextField;
- (IBAction)saveQuoteButton:(id)sender;
@end
AddQuoteViewController.m
#import "AddQuoteViewController.h"
#import "MLPAutoCompleteTextField.h"
#import "AuthorAutoSuggestTableViewCell.h"
#import <QuartzCore/QuartzCore.h>
@implementation AddQuoteViewController
- (void)viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShowWithNotification:) name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHideWithNotification:) name:UIKeyboardDidHideNotification object:nil];
[self.authorTextField setBorderStyle:UITextBorderStyleRoundedRect];
}
- (void)keyboardDidShowWithNotification:(NSNotification *)aNotification {
[self.author setAlpha:0];
}
- (void)keyboardDidHideWithNotification:(NSNotification *)aNotification {
[self.author setAlpha:1];
[self.authorTextField setAutoCompleteTableViewHidden:NO];
}
- (NSArray *)possibleAutoCompleteSuggestionsForString:(NSString *)string {
NSArray *sample = @[@"Ape", @"Bird", @"Cat", @"Dog"];
return sample;
}
- (BOOL)autoCompleteTextField:(MLPAutoCompleteTextField *)textField
shouldConfigureCell:(UITableViewCell *)cell
withAutoCompleteString:(NSString *)autocompleteString
withAttributedString:(NSAttributedString *)boldedString
forRowAtIndexPath:(NSIndexPath *)indexPath;
{
return YES;
}
I'm testing on an iPad 1 running iOS 5.1. There is a concurrency problem where a crash occurs in MLPAutoCompleteFetchOperation
because sentinelSemaphore
is signalled in -[MLPAutoCompleteFetchOperation cancel]
while it is nil because it has never been created.
If a MLPAutoCompleteTextFieldDelegate
doesn't implement autoCompleteTextField:possibleCompletionsForString:completionHandler:
then the semaphore will never be created in -[MLPAutoCompleteFetchOperation main]
. Therefore if the user is typing fast enough that fetchAutoCompleteSuggestions
gets called a second time while there is an operation on the queue, it will get cancelled which will call the operation's cancel
method which attempts to signal the semaphore which was never created.
I suggest putting a guard to make sure the semaphore isn't nil in the -[MLPAutoCompleteFetchOperation cancel] method like so:
- (void) cancel
{
if (sentinelSemaphore) dispatch_semaphore_signal(sentinelSemaphore);
[super cancel];
}
The code checks for this case then asserts. Therefore MLPAutoCompleteTextField crashes on iOS versions less than 6. The README states it supports iOS 5.0+
lines 249-250 of MLPAutoCompleteTextField.m (as of commit 0443f02):
BOOL attributedTextSupport = [cell.textLabel respondsToSelector:@selector(setAttributedText:)];
NSAssert(attributedTextSupport, @"Attributed strings on UILabels are not supported before iOS 6.0");
I need to set my autocomplete field to also use a UITextField delegate, however doing so I get the following:
Obj-C -[MLPAutoCompleteTextField title]: unrecognized selector sent to instance 0x17647d70
Love this component by the way, works great otherwise.
The result tableView appears transparent always, I tried to set the property autoCompleteTableBackgroundColor but nothing happens still transparent
Is there any easy way to style the autocomplete table view positioning, border color/width/radius, text color/positioning etc. or do I have to tamper with the source code?
For example the text in the autocomplete table view is black in the example project but in my project it's light blue, and has a border that also is light blue.
So this is just a question on styling the appearance of the autocomplete table view and not really an issue, but I didn't know where else to ask.
Hello all!
I want to scroll table view with autocomplete to top, after user typer in text field. It's possible with this component?
The Demo code is not running on iPhone 4 IOS 6.1.3 while running on iPhone 4S (6.1.3)
and iPhone 5 (6.0.4)
Any Ideas ?
I'm using your github project for my developments. Thanks for this. This is very simple to use and I did some changes according to our requirements.
Earlier I used this in xcode 5.1 development and now i converted this into xcode 6.1 (Objective C). But when i run the same application in ios 7 and 8 in iPad by using xcode 6, self.autoCompleteTableView is not showing the top view. It shows in the bottom view.
It was working well in xcode 5.1 build.
XCode 5.1 build
XCode 6.1 build
I want to show this as XCode 5.1 build.
Below is my code.
-(void)expandDropDownAutoCompleteTableForNumberOfRows:(NSInteger)numberOfRows
{
[self resetDropDownAutoCompleteTableFrameForNumberOfRows:numberOfRows];
if(numberOfRows && (self.autoCompleteTableViewHidden == NO)){
[self.autoCompleteTableView setAlpha:1];
if(!self.autoCompleteTableView.superview){
if([self.autoCompleteDelegate
respondsToSelector:@selector(autoCompleteTextField:willShowAutoCompleteTableView:)]){
[self.autoCompleteDelegate autoCompleteTextField:self
willShowAutoCompleteTableView:self.autoCompleteTableView];
}
}
[self.superview bringSubviewToFront:self];
UIView *rootView;
if (gaiDevice == iPad)
{
rootView = [UIApplication sharedApplication].keyWindow;
[rootView insertSubview:self.autoCompleteTableView aboveSubview:[UIApplication sharedApplication].keyWindow.rootViewController.view];
}
else
{
[rootView insertSubview:self.autoCompleteTableView
belowSubview:self];
rootView = [self.window.subviews objectAtIndex:0];
[rootView insertSubview:self.autoCompleteTableView
belowSubview:self];
}
[self.autoCompleteTableView setUserInteractionEnabled:YES];
if(self.showTextFieldDropShadowWhenAutoCompleteTableIsOpen){
[self.layer setShadowColor:[[UIColor blackColor] CGColor]];
[self.layer setShadowOffset:CGSizeMake(0, 1)];
[self.layer setShadowOpacity:0.35];
}
} else {
[self closeAutoCompleteTableView];
[self restoreOriginalShadowProperties];
[self.autoCompleteTableView.layer setShadowOpacity:0.0];
}
}
So how can I show this in iPad's top view on the popover in xcode 6 build??
Thank you!
Let's say I have a service that fetches auto complete suggestions. I have to reload the data to show the web service response. Any ideas?
Hi,
I'm trying to get the tableview keyboard input accessory running but somehow can't get it working. After a bit of debugging I found out it's related the storyboard and using autolayout. When I disable auto layout the tableview is shown. When I enable autolayout the frame of the tableview is set to 0,0,0,0 I guess because the MLPAutoCompleteTextField has no dimensions yet. Hope you know how to fix this.
Thanks!
Bart
Hi,
I'm trying to figure out a way to remove the autocompleteString from a custom UITableViewCell.
In the viewController:viewDidLoad I registered the custom UITableViewCell class & Nib with
registerAutoCompleteCellClass:forCellReuseIdentifier:
registerAutoCompleteCellNib:bundle:forCellReuseIdentifier:
then, in the delegate method
(BOOL)autoCompleteTextField:(MLPAutoCompleteTextField *)textField shouldConfigureCell:(UITableViewCell *)cell withAutoCompleteString:(NSString *)autocompleteString withAttributedString:(NSAttributedString *)boldedString forAutoCompleteObject:(id<MLPAutoCompletionObject>)autocompleteObject forRowAtIndexPath:(NSIndexPath *)indexPath
I tried to remove the autocompleteString from the custom cell
autocompleteString = nil; boldedString = nil; cell.textLabel.text = nil;
Unfortunately though, the autocompleteString keep showing inside the custom cell.
How to remove it ?
Thanks.
From the readme, I implemented autoCompleteTextField
method, but I still get the following error message.
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'An autocomplete datasource must implement either autoCompleteTextField:possibleCompletionsForString: or autoCompleteTextField:possibleCompletionsForString:completionHandler:'
AutoCompleteDataSource.h
#import "MLPAutoCompleteTextFieldDataSource.h"
@interface StationAutoCompleteSource : NSObject <MLPAutoCompleteTextFieldDataSource>
- (void)autoCompleteTextField:(MLPAutoCompleteTextField *)textField
possibleCompletionsForString:(NSString *)string
completionHandler:(void(^)(NSArray *suggestions))handler;
@property (strong, nonatomic) NSArray *allCountries;
@property (strong, nonatomic) NSArray *countryObjects;
@property (assign) BOOL testWithAutoCompleteObjectsInsteadOfStrings;
@end
AutoCompleteDataSource.m
- (void)autoCompleteTextField:(MLPAutoCompleteTextField *)textField
possibleCompletionsForString:(NSString *)string
completionHandler:(void (^)(NSArray *))handler
{
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
dispatch_async(queue, ^{
NSArray *completions;
completions = [self allCountries];
handler(completions);
});
}
I felt suggestions for one or two characters are pretty irrelevant. Can i make some changes to the code so that suggestions are displayed only after 3 or more characters are entered into the text field ?
Autocomplete tableview without any rows still appears on screen with alpha=0. That's prevents views laying under this tableview catching any touches.
I am using a web method response to generate data. How can i handle make autoCompleteTextField:possibleCompletionsForString:completionHandler call on webmethod response
TextField goes up too much for Chinese input.
There is something wrong with the location adjustment.
On iOS 5 which doesn't use ARC, dispatch objects such as semaphores must be explicitly released. In MLPAutoCompleteFetchOperation sentinelSemaphore is created but never released. The semaphore will leak because without ARC, you need to call dispatch_release()
when you're done with it. (see https://developer.apple.com/library/mac/documentation/Performance/Reference/GCD_libdispatch_Ref/Reference/reference.html#//apple_ref/doc/uid/TP40008079-CH1-SW2)
which says:
The behavior of dispatch queues in an automatic reference counting environment varies depending on the deployment target that you choose for a given build target.
If you need to use manual reference counting in an ARC-enabled app with a later deployment target (for maintaining compatibility with existing code), you can disable Objective-C-based dispatch objects by adding -DOS_OBJECT_USE_OBJC=0 to your compiler flags.
Hi,
First of all thanks for a great plugin.
I'm using the example project and I've been trying to add the MLPAutoCompleteTextField to the MLPViewController programatically.
I've deleted the view.xib file, but I cannot seem to get the custom text field to appear in the view programatically. Could you please advise how I can achieve this. I've included my viewDidLoad implementation below.
Thanks again,
Patrick
- (void)viewDidLoad
{
[super viewDidLoad];
self.autocompleteTextField = [[MLPAutoCompleteTextField alloc] initWithFrame:CGRectMake(10, 200, 300, 40)];
self.autocompleteTextField.delegate = self;
self.autocompleteTextField.autoCompleteDataSource = self;
self.autocompleteTextField.autoCompleteDelegate = self;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShowWithNotification:) name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHideWithNotification:) name:UIKeyboardDidHideNotification object:nil];
//Supported Styles:
//[self.autocompleteTextField setBorderStyle:UITextBorderStyleBezel];
//TODO[self.autocompleteTextField setBorderStyle:UITextBorderStyleLine];
//[self.autocompleteTextField setBorderStyle:UITextBorderStyleNone];
[self.autocompleteTextField setBorderStyle:UITextBorderStyleRoundedRect];
//You can use custom TableViewCell classes and nibs in the autocomplete tableview if you wish.
[self.autocompleteTextField registerAutoCompleteCellClass:[MLPCustomAutoCompleteCell class]
forCellReuseIdentifier:@"CustomCellId"];
[self.view addSubview:self.autocompleteTextField];
}
Hi Eddy,
First I wanted to say congrats about the great work with MLPAutoCompleteTextField. I started playing with it recently. So here are my goals:
a) I want to search on a large array of strings. I experimented with 10K and it is not bad (~1sec). Do you have any ideas how to optimize for larger arrays? Perhaps some caching?
b) I have already pre-sorted the array. Does it helps? I cannot seem to find in your code if it sorts the array or not.
c) How can I change your code so that the search takes place on multiple words?I want to do this because my array contains entries with multiple words. Basically what I want to achieve is this: the user types in one word, the word is matched as it does now, but then when the user types in a second word, then the second word is tried to be matched with the results of the first word. Could you point me to your code?
d) Finally you mention that you want to do have some ranking in the array of strings. How could I modify your code to address this?
Once again thank you for your help. Great work!
-Alex
hi Eddy,
i've applied these lines of code :
self.autoCompleteTableView.layer.masksToBounds=NO;
self.autoCompleteTableView.layer.shadowOffset=CGSizeMake(1,1);
self.autoCompleteTableView.layer.shadowRadius=5.0f;
self.autoCompleteTableView.layer.shadowOpacity=1;
self.autoCompleteTableView.layer.shadowColor=[UIColor orangeColor].CGColor;
in the method -setNoneStyleForAutoCompleteTableView
but,i couldn't see them on the tableview.
Hello,
I really appreciate your work on MLPAutoCompleteTextField. I would like to use it in our project, because it fits our requirements perfectly. But I am now facing an issue when the autoCompleteTableView is displayed. I am currently using v1.5 added to project via Pods.
Here is my situation:
I have to generate a mask view dynamically from out a mask model that I retrieve by a web service. The mask model contains various objects. I made a screenshot to make things easier. ;)
Now I subclassed UIView a few times (Mask, Group, Column, Entry) and generate the view when receiving the maskModel from the server. In my testcase I used the MLPAutoCompleteField as inputField in every entry. Now here is my issue:
When I type into an inputField the tableView will be displayed. But as you can see it is overlayed by the next group view. I had set clipsToBounds and masksToBounds to NO in every view in the hierarchy. But it seems to have no effect. I inspected your code an found a possible issue. The tableView will be inserted as subview into the superview of the inputField (in my case it's the MaskEntry - grey color).
While browsing GitHub I found out, that you fixed an similar issue by adding the tableView to the root view. So I replaced my version by the current state. But that the table view is completely misplaced and won't be diplayed under the input field.
Is there anything I am doing wrong? Any solutions?
I would really appreciate some help!
Best regards,
SlimShady0208
The IBOutlet autoCompleteDelegate is accessed from the initializer (init-> initialize-> styleAutoCompleteTableForBorderStyle:
), but the outlets are not set while the designated initializer chain is called, so delegate method autoCompleteTextField:shouldStyleAutoCompleteTableView:forBorderStyle:
will never get called while the class is initializing
I created a pull request #73 that should fix this issue.
Hi,
I'm trying to move down the autocomplete table view, since it appears in the middle of the AutoCompleteTextfield and covers half of the text. Is there any property or method to achieve this ?
I tried with autoCompleteTableOriginOffset/setAutoCompleteTableOriginOffset (in both viewWillAppear and viewDidLoad), but nothing moves or changes.
I'm using XCode Version 5.1.1 (5B1008), iOS 7.1.1 with storyboard.
Thanks
By default, the table height fits about 2.5 results. This value should be adjustable so one could take advantage of all space available, if desired.
Also, when the results are show as keyboard accessory, the heigh does not decrease when there are less autocomplete suggestions available (ie only one).
Moreover, I noticed that using the keyboard accessory, when there's no suggestions, there's still an invisible table or view on top of the keyboard, so I cannot tap the superview to dismiss the keyboard. This does not happen with the dropdown.
I am using the autocomplete on iPad, and my app supports any orientation. The autocomplete table is able to show up correctly in any orientation, but when it is already open and I rotate the device, the table does not follow the frame changes to match the new position of the text field.
Trying to switch from iOS 7.1 to iOS 8, I noticed that the autoCompleteTableView doesn't appear anymore. I double checked that data is fetched correctly, so it should be something related to the tableview's visibility.
Instead of the tableview, only a bottom shadow appears.
I'm on OSX 10.9.5 (Mavericks), using XCode 6.0.1 (6A317)
My app is written with Objective-C, no swift at all.
can you add the option to appear a empty table while its being load from the web service. or else we cant find whether the function is working or not.
in other words there should be activity indicator until the data is fetched from the server to app.
I already have a very long list of numbers and I'd like to see if there is anyway I can only show the results that have matched (at least by 1 letter) what the user has entered?
Any suggestions?
For the app I'm working on, there is a form with some textfields. The autocomplete works without a problem inside a regular view in a view controller, but there are some z-index issues when the autocomplete textfield is inside a static cell of a UITableView.
It's hard to show with screenshots, but you can see the form below with the autocomplete suggestions showing up. When you try and click on one it dismisses the dialog and selects the MRN field below the suggestions.
I have used this library in my current project, but I dnt know what is the reason but this make the Device stuck even with opened keyboard too.
in Stack trace, I found it always raise this issue when i try too type and crashes at
dispatch_semaphore_wait(sentinelSemaphore, DISPATCH_TIME_FOREVER);
from -main method of MLPAutocompleteTextField.m
Very surprising part it that When i try to type something from Keyboard attached to machine then its not crashing but when i use the On screen keyboard of simulator It crashes everytime.
Readme.md
says 1.6
is in Cocoapods, but Cocoapods only shows 1.5
AutoComplete View does not disappear when clicked on suggestion using with textfields in static tableview.
I have a NSMutablearray with NSDictionary objects and keys, for example: countryId and countryName. How can I get the countryId of selected row?
hey, i wanna to know how to i got notified via delegate when there are no suggestions matching the text field string
Just in iPhone 5, I have some fields not showed, it's there... but i can't see. Doesn't happen in simulator, only in iPhone 5. Does anyone knows why?
I implement simple datasource for autocomplete list and show suggestions, but when i try to select one of the suggestion it do nothing.
I also try to implement some delegate methods like:
- (void)autoCompleteTextField:(MLPAutoCompleteTextField *)textField
didSelectAutoCompleteString:(NSString *)selectedString
withAutoCompleteObject:(id<MLPAutoCompletionObject>)selectedObject
forRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"select: %@", selectedString);
}
Nothing happens.
I am fairly new to IOS, and am sure I am missing something. I am unable to connect the autoCompleteDataSource to my IBOutlet in my view, but I can manually connect it by calling setAutoCompleteDataSource
. Relevant code is below.
GBProductAutocomplete.h
#import <Foundation/Foundation.h>
#import "MLPAutoCompleteTextFieldDataSource.h"
@interface GBProductAutocomplete : NSObject <MLPAutoCompleteTextFieldDataSource>
@end
GBProductAutocomplete.m
#import "GBProductAutocomplete.h"
@implementation GBProductAutocomplete
- (void)autoCompleteTextField:(MLPAutoCompleteTextField *)textField
possibleCompletionsForString:(NSString *)string
completionHandler:(void (^)(NSArray *))handler
{
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
dispatch_async(queue, ^{
NSArray *completions;
completions = [NSArray arrayWithObjects:@"hello", @"world", nil];
handler(completions);
});
}
@end
GBViewController.h
#import <UIKit/UIKit.h>
#import "MLPAutoCompleteTextFieldDelegate.h"
@class GBProductAutocomplete;
@interface GBManualAddViewController : UIViewController <UITextFieldDelegate, MLPAutoCompleteTextFieldDelegate>
@property (weak, nonatomic) IBOutlet MLPAutoCompleteTextField *autocompleteTextField;
@property (strong, nonatomic) IBOutlet GBProductAutocomplete *autocompleteDataSource;
@property (weak, nonatomic) IBOutlet MLPAutoCompleteTextField *textField;
@end
GBViewController.m
#import "GBManualAddViewController.h"
#import "MLPAutoCompleteTextField.h"
#import "GBProductAutocomplete.h"
@interface GBManualAddViewController ()
@end
@implementation GBManualAddViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
// [self.textField setAutoCompleteDataSource:[[GBProductAutocomplete alloc] init]];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (BOOL)autoCompleteTextField:(MLPAutoCompleteTextField *)textField
shouldConfigureCell:(UITableViewCell *)cell
withAutoCompleteString:(NSString *)autocompleteString
withAttributedString:(NSAttributedString *)boldedString
forAutoCompleteObject:(id<MLPAutoCompletionObject>)autocompleteObject
forRowAtIndexPath:(NSIndexPath *)indexPath;
{
//This is your chance to customize an autocomplete tableview cell before it appears in the autocomplete tableview
NSString *filename = [autocompleteString stringByAppendingString:@".png"];
filename = [filename stringByReplacingOccurrencesOfString:@" " withString:@"-"];
filename = [filename stringByReplacingOccurrencesOfString:@"&" withString:@"and"];
[cell.imageView setImage:[UIImage imageNamed:filename]];
return YES;
}
- (void)autoCompleteTextField:(MLPAutoCompleteTextField *)textField
didSelectAutoCompleteString:(NSString *)selectedString
withAutoCompleteObject:(id<MLPAutoCompletionObject>)selectedObject
forRowAtIndexPath:(NSIndexPath *)indexPath
{
if(selectedObject){
NSLog(@"selected object from autocomplete menu %@ with string %@", selectedObject, [selectedObject autocompleteString]);
} else {
NSLog(@"selected string '%@' from autocomplete menu", selectedString);
}
}
@end
If I uncomment the line [self.textField setAutoCompleteDataSource:[[GBProductAutocomplete alloc] init]];
in viewDidLoad
the autocomplete will work, but I cannot figure out why I cannot drag from the outlet in the nib to connect the property.
Is it supported? I'm having trouble with it...
When the super view of the textField is small, the tableView is clipped. Is there is any way to add the table view as a subview to the window instead of its superview?, i tried to do that but the table view covered the half of the textField
In the readme, it lists '~> 1.6'
as the target for installing with cocoapods. When I tried pod install
with that version, it gave me
[!] Unable to satisfy the following requirements:
- `MLPAutoCompleteTextField (~> 1.6)` required by `Podfile`
Also, https://github.com/CocoaPods/Specs/tree/master/Specs/MLPAutoCompleteTextField only lists up to 1.5, so it seems like 1.5 should be the version in the readme instructions.
When I compile in Xcode 5.1.1 for a 64-bit Simulator, I get 3 warnings.
I have added them here, incl. a proposed fix. I hope you can effectuate these changes.
Proposed solution:
NSUInteger n = [dataA length];
Proposed solution:
NSUInteger m = [dataB length];
Proposed solution:
return [NSString stringWithFormat:@"{%ld,%ld}",(long)indexPath.section,(long)indexPath.row];
Could you please add a demo using storyboard.
I have problems figuring out how to connect textfields to datasources, and since I am using storyboards I think that a sample would help.
Thanks
Is it possible to auto suggest item based on user input. fx. I have the following url "https://itunes.apple.com/search?term=" where users have to enter a search term?
I have tried to the following:
(void)autoCompleteTextField:(MLPAutoCompleteTextField *)textField
possibleCompletionsForString:(NSString *)string
completionHandler:(void (^)(NSArray *))handler
{
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
dispatch_async(queue, ^{
if(self.simulateLatency){
CGFloat seconds = arc4random_uniform(4)+arc4random_uniform(4); //normal distribution
NSLog(@"sleeping fetch of completions for %f", seconds);
sleep(seconds);
}
NSMutableArray* jsonObject = [[NSMutableArray alloc]init];
NSMutableArray* suggestionlist = [[NSMutableArray alloc]init];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",baseURL,textField.text]]];
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSError* error;
jsonObject = [NSJSONSerialization
JSONObjectWithData:response
options:0
error:&error];
for (int i = 0 ; i < jsonObject.count; i++) {
NSString* artistName = [[jsonObject objectAtIndex:i] objectForKey:@"artistId"];
[suggestionlist addObject:artistName];
}
handler(suggestionlist);
});
}
But I got the following error:
GAIUncaughtExceptionHandler(NSException ) (GAIUncaughtExceptionHandler.m:41): Uncaught exception: data parameter is nil
2014-05-15 11:49:54.224 MLPAutoCompleteDemo[6349:5503] GoogleAnalytics 2.0b4 void GAIUncaughtExceptionHandler(NSException *) (GAIUncaughtExceptionHandler.m:38): Bailing on multiple uncaught exceptions: data parameter is nil
2014-05-15 11:49:54.224 MLPAutoCompleteDemo[6349:5503] ** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'data parameter is nil'
Any suggestions why it is not working?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.