I want to separate two text fields in a table view controller. I want to add a drop down before one text field, but if I am adding a drop down for that text field it is automatically adding for both text fields. Please can you let me know how to separate those text fields and add a drop down for the same?
Below code for editing the text fields:
#import "IconEditableCell.h"
@interface IconEditableCell () <UITextFieldDelegate>
@property (nonatomic, strong) UIImage *icon;
@property (nonatomic, strong) UIImage *selectedIcon;
@end
@implementation IconEditableCell
(instancetype)cellWithPlaceholderText:(NSString *)placeholder
icon:(NSString *)icon
selectedIcon:(NSString *)selectedIcondelegate:(id<IconEditableCellDelegate>)delegate {
NSArray *views =&#9;&#9;[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil];
IconEditableCell *cell = [views firstObject];
[cell setupWithPlaceholderText:placeholder icon:icon selectedIcon:selectedIcon delegate:delegate];
return cell;
}
(void)setupWithPlaceholderText:(NSString *)placeholder
icon:(NSString *)icon
selectedIcon:(NSString *)selectedIcondelegate:(id<IconEditableCellDelegate>)delegate {
self.icon = [UIImage imageNamed:icon];
self.selectedIcon = [UIImage imageNamed:selectedIcon];
self.iconImageView.image = self.icon;
self.textField.placeholder = placeholder;
self.textField.delegate = self;
self.delegate = delegate;
}
#pragma mark - UITextFieldDelegate
(void)textFieldDidBeginEditing:(UITextField *)textField {
self.iconImageView.image = self.selectedIcon;
if ([self.delegate respondsToSelector:@selector(editableCellDidBeginEditing:)]) {
[self.delegate editableCellDidBeginEditing:self];}
}
(void)textFieldDidEndEditing:(UITextField *)textField {
self.iconImageView.image = self.icon;
if ([self.delegate respondsToSelector:@selector(editableCellDidEndEditing:)]) {
[self.delegate editableCellDidEndEditing:self];}
}
(BOOL)textFieldShouldReturn:(UITextField *)textField {
if ([self.delegate respondsToSelector:@selector(editableCellShouldReturn:)]) {
return [self.delegate editableCellShouldReturn:self];} else {
&#9;&#9;return YES;
}
}
@end
Please find below code where we are trying to add the code in UITableViewController class:
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell;
if (indexPath.row < self.editableCells.count) {
cell = self.editableCells[indexPath.row];} else {
cell = self.buttonCells[indexPath.row - self.editableCells.count];}
User *user = [User currentUser];
self.selectedVehicle = [user.assistant vehicle];
if (cell == self.vehicleCell) {
if ([user.assistant vehicle] != nil) {
Vehicle *v = [user.assistant vehicle];
NSString *vehicle = [NSString stringWithFormat:@"%@ (%@)", v.vehicleTypeDescription, v.registrationNumber ];
if (v.registrationNumber == nil) {
vehicle = v.vehicleTypeDescription;&#9;&#9;&#9;&#9;} else
if (v.vehicleTypeDescription == nil) {
vehicle = v.registrationNumber;&#9;&#9;&#9;&#9;&#9;&#9;}
self.vehicleCell.titleLabel.text = vehicle;&#9;&#9;} else {
[self.vehicleCell titleLabel].text = @"";&#9;&#9;}
} else
if (cell == self.phoneCell) {
[self.phoneCell textField].text = [user.assistant phoneNumber];&#9;&#9;} else
if (cell == self.mailCell) {
[self.mailCell textField].text = [user.assistant email];&#9;&#9;&#9;&#9;}
return cell;
}
Can you please suggest me what can I do for this, where I want to separate two text fields and want to add a dropdown before one text field?
Selecting any option will automatically load the page