Thank you for reading,
I have two UITextFields
(along with some labels) inside a UICollectionViewCell
. I can select both text fields in the simulator, for iPhone 6, 6+, 5, 5s, 4s, all iOS8.
When I hook up my iPhone, an iPhone 5c iOS7 (not-sim), I can only select the top left portion of the top UITextField
. An answer would suggest how to select both text fields, and explore other possible reasons someone wouldn't be able to select text fields, as well as possible de-bug methods for this. For those wondering, I will upgrade to ios8 as soon as I get this app working 100% in ios7.
Solutions I've tried:
- Make sure the textField is inside the known superview
- Create a new project, get that working correctly, and copy everything as exact as possible
- Shifting the Text fields so the bottom one is on top
- This had the result of letting me select the new "top" field in the same small hit area.
- Selecting the UICollectionView Cell and auto setting the first responder. This does not work as I want the user to choose which field to make first responder.
- Set all background elements to a different colour to ensure nothing was overlapping the TextField
- Set
UICollectionView
to be Editable -- it only works withUITableViews
- Make sure the collectionview elements are in the right order
- Copying and pasting the "Good Text Field" and seeing if that is then selectable.
- Deleting the entire
ViewController
and starting again. - Make sure the
UICollectionView
cell has "User Interaction Enabled"
My Current set up
- Heres a screenshot of the storyboard
UICollectionView: data-source & delegate = it's superview (UIViewController)
UICollectionViewCell
: has 4 outlets linking to a custom cellUITextFields
: Delegate is set toUIViewController
- Referencing outlets leading to the Cell
EditingDidBegin
andEditingDidEnd
methods handled inUIViewController
- One textfield uses a picker input view, the other a keypad
To be clear:
- I can get the keyboard to pop up in the simulator, and on my phone in the small hit area
- This is not about retrieving the data from text fields.
- I could get the test project working but the main project refuses to accept taps in the
UITextFields
Relevant Code - UIViewController .m
Interface - Private.m
@interface EnterFinalHRViewController ()
// The current responder showing a keyboard.
@property (nonatomic, assign) id currentResponder;
Text Field Methods
- (IBAction)editingDidBegin:(UITextField *)textField {
self.currentResponder = textField;
}
- (IBAction)resignOnTap:(id)sender {
//called from a single tap on the view, gesture recognizer is present
//called when the text field says "Editing did End"
[self.currentResponder resignFirstResponder];
}
//implementation of the cell
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath{
static NSString *cellIdentifier = @"swimmerReview";
FinalHeartRateCollectionViewCell *cell = (FinalHeartRateCollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath]; //reuse the cell
Lane *lane = [_lanes objectAtIndex:indexPath.section]; //lanes hold swimmers, so get the lane
Swimmer *swimmer = [lane.swimmers objectAtIndex:indexPath.row]; //swimmers are in the lane, so get the right swimmer
if (swimmer.actualSwimmerName) {
cell.swimmerFullName.text = swimmer.actualSwimmerName;
} else {
cell.swimmerFullName.text = @"Assign Swimmer";
}
cell.finalHeartRate.text = @"--";
//Person Picker is a PickerView that lets the user select a swimmer
cell.swimmerFullName.inputView = PersonPicker;
cell.averageStrokeRate.text = [NSString stringWithFormat:@"Avg SR: %.f", swimmer.strokeRateAvg];
cell.AveragePace.text = [@"Avg Pace: " stringByAppendingString: swimmer.setSplitAvg];
return cell;
}
The Question
An answer would suggest how to select both text fields, and explore other possible reasons someone wouldn't be able to select text fields, as well as possible de-bug methods for this.
Quick shout out to all the contributors at SO, you've all been such a resource, and I have read and learned so much from all the questions you have answered. I just couldn't figure it out this time.