Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add image to search results. #85

Merged
merged 1 commit into from
Mar 29, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions TITokenField.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
- (NSString *)tokenField:(TITokenField *)tokenField displayStringForRepresentedObject:(id)object;
- (NSString *)tokenField:(TITokenField *)tokenField searchResultStringForRepresentedObject:(id)object;
- (NSString *)tokenField:(TITokenField *)tokenField searchResultSubtitleForRepresentedObject:(id)object;
- (UIImage *)tokenField:(TITokenField *)tokenField searchResultImageForRepresentedObject:(id)object;
- (UITableViewCell *)tokenField:(TITokenField *)tokenField resultsTableView:(UITableView *)tableView cellForRepresentedObject:(id)object;
- (CGFloat)tokenField:(TITokenField *)tokenField resultsTableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
@end
Expand Down
10 changes: 10 additions & 0 deletions TITokenField.m
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N

if (!cell) cell = [[UITableViewCell alloc] initWithStyle:(subtitle ? UITableViewCellStyleSubtitle : UITableViewCellStyleDefault) reuseIdentifier:CellIdentifier];

[cell.imageView setImage:[self searchResultImageForRepresentedObject:representedObject]];
[cell.textLabel setText:[self searchResultStringForRepresentedObject:representedObject]];
[cell.detailTextLabel setText:subtitle];

Expand Down Expand Up @@ -299,6 +300,15 @@ - (NSString *)searchResultSubtitleForRepresentedObject:(id)object {
return nil;
}

- (UIImage *)searchResultImageForRepresentedObject:(id)object {
if ([_tokenField.delegate respondsToSelector:@selector(tokenField:searchResultImageForRepresentedObject:)]) {
return [_tokenField.delegate tokenField:_tokenField searchResultImageForRepresentedObject:object];
}

return nil;
}


- (void)setSearchResultsVisible:(BOOL)visible {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){

Expand Down