EddyBorja / MLPAutoCompleteTextField

UITextfield subclass with autocomplete menu. For iOS.
Other
1.21k stars 223 forks source link

Not working on my app. #2

Closed kennethjohnbalgos closed 11 years ago

kennethjohnbalgos commented 11 years ago

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;
}
EddyBorja commented 11 years ago

Did you verify the autoCompleteDataSource property of the textfield is set to your AddQuoteViewController?

kennethjohnbalgos commented 11 years ago

Yes, take a look: Screenshot 2013-03-03 at 23 49 36

EddyBorja commented 11 years ago

Is your project available somewhere? It'd be easier to diagnose the problem.

kennethjohnbalgos commented 11 years ago

You can see the Author Field at "Get Started" > "Quotebook (Tab Bar)" > "Add Button (Navigation Bar)" I'm using cocoapods for this project. Thanks!

Aside from assigning the delegates from storyboard, I also written codes to assign it manually:

[self.authorTextField setDelegate:self];
[self.authorTextField setAutoCompleteDataSource:self];
[self.authorTextField setAutoCompleteDelegate:self];
EddyBorja commented 11 years ago

Thanks, I'll take a look when I get home.

kennethjohnbalgos commented 11 years ago

Thank you, I hope we can fix this :)

EddyBorja commented 11 years ago

I have been having some issues with getting your project to compile, "ld: library not found for -lPods"

Not sure why

kennethjohnbalgos commented 11 years ago

Have you initialized and updated the submodules? Have you successfully installed the content of Podfile? Are you working with the iQuotebook.xcworkspace file?

kennethjohnbalgos commented 11 years ago

I managed to run the app using the following commands:

git submodule init
git submodule update
pod install
open iQuotebook.xcworkspace
*** Change the build settings to "iQuotebook > iPhone 6.1 Simulator"
*** Build and Run the project

I tried it and it's working.

EddyBorja commented 11 years ago

Hmm, for some reason I don't have the workspace file, I was looking for it earlier but assumed it wasn't set up that way. I also can't seem to do pod install because it doesn't find the MLPAutoCompleteTextField pod

kennethjohnbalgos commented 11 years ago

I'm not sure what's happening, I was able to run the app when I tried to clone it. I pushed the workspace file, I'm not sure if that will help. Please update me.

EddyBorja commented 11 years ago

I finally got the project to build, the command was actually pod update not pod install. I'm going to investigate the issue now.

kennethjohnbalgos commented 11 years ago

Great! Thanks :)

EddyBorja commented 11 years ago

Ok, I found the issue, I'll be pushing a bug fix soon.

EddyBorja commented 11 years ago

I pushed out version 1.1 with the bugfix, check it out and see if it solves your problem now.

kennethjohnbalgos commented 11 years ago

Cool :) It's working now. Thanks for the best support.

EddyBorja commented 11 years ago

No problem, thanks for reporting this issue.