diff --git a/MLPAutoCompleteTextField/MLPAutoCompleteTextField.h b/MLPAutoCompleteTextField/MLPAutoCompleteTextField.h index 855b365..9a8ff92 100644 --- a/MLPAutoCompleteTextField/MLPAutoCompleteTextField.h +++ b/MLPAutoCompleteTextField/MLPAutoCompleteTextField.h @@ -31,6 +31,8 @@ + (NSString *) accessibilityLabelForIndexPath:(NSIndexPath *)indexPath; +@property (nonatomic, strong) UIView* attachmentView; + @property (strong, readonly) UITableView *autoCompleteTableView; // all delegates and datasources should be weak referenced diff --git a/MLPAutoCompleteTextField/MLPAutoCompleteTextField.m b/MLPAutoCompleteTextField/MLPAutoCompleteTextField.m index 674b4a9..f3a5011 100644 --- a/MLPAutoCompleteTextField/MLPAutoCompleteTextField.m +++ b/MLPAutoCompleteTextField/MLPAutoCompleteTextField.m @@ -449,8 +449,13 @@ - (void)expandDropDownAutoCompleteTableForNumberOfRows:(NSInteger)numberOfRows [rootView insertSubview:self.autoCompleteTableView belowSubview:self]; #else - [self.superview insertSubview:self.autoCompleteTableView - belowSubview:self]; + if (self.attachmentView) { + [self.attachmentView addSubview:self.autoCompleteTableView]; + [self.attachmentView bringSubviewToFront:self.autoCompleteTableView]; + } else { + [self.superview insertSubview:self.autoCompleteTableView + belowSubview:self]; + } #endif [self.autoCompleteTableView setUserInteractionEnabled:YES]; if(self.showTextFieldDropShadowWhenAutoCompleteTableIsOpen){ @@ -843,7 +848,11 @@ - (CGRect)autoCompleteTableViewFrameForTextField:(MLPAutoCompleteTextField *)tex if (CGRectGetWidth(self.autoCompleteTableFrame) > 0){ frame = self.autoCompleteTableFrame; } else { - frame = textField.frame; + if (self.attachmentView) { + frame = [self.attachmentView convertRect:textField.bounds fromView:textField]; + } else { + frame = textField.frame; + } frame.origin.y += textField.frame.size.height; }