EddyBorja / MLPAutoCompleteTextField

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

AutoCompleteTextField Z-Index Issues Inside of UITableView #104

Closed shawn458 closed 8 years ago

shawn458 commented 8 years ago

I am having a problem where the AutoCompleteTextField table is covered up by other cells in my UITableView.

screenshot

I am dynamically building the field in my cellForRowAtIndexPath method.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier;

    if (indexPath.row == 1) {
        CellIdentifier = @"AutoCompleteCell";

        AutoCompleteTextFieldTableViewCell *cell = (AutoCompleteTextFieldTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

        if (cell == nil) {
            cell = [[AutoCompleteTextFieldTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        }

        cell.label.text = self.cellTitles[indexPath.row];
        cell.textfield.delegate = self;
        cell.textfield.autoCompleteDataSource = self;
        cell.textfield.autoCompleteDelegate = self;

        [cell.textfield setAutoCompleteTableAppearsAsKeyboardAccessory:NO];

        NSString *key = cell.label.text;

        if ([self.dictOfLabelsAndTexts valueForKey:key] != nil) {
            cell.textfield.text = [self.dictOfLabelsAndTexts valueForKey:key];
        } else {
            cell.textfield.text = @"";
        }

        return cell;
    } else {
        CellIdentifier = @"Cell";

        TextFieldTableViewCell *cell = (TextFieldTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

        if (cell == nil) {
            cell = [[TextFieldTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        }

        cell.label.text = self.cellTitles[indexPath.row];
        cell.textfield.delegate = self;

        NSString *key = cell.label.text;

        if ([self.dictOfLabelsAndTexts valueForKey:key] != nil) {
            cell.textfield.text = [self.dictOfLabelsAndTexts valueForKey:key];
        } else {
            cell.textfield.text = @"";
        }

        return cell;
    }
}

Is this not possible?

shawn458 commented 8 years ago

This has been resolved. I added a view to my uitableview's header and placed the textfield inside of there.