Reputation: 32207
Current Code:
- (void)textFieldDidBeginEditing:(UITextField *)textField {
NSLog(@"begin edit: %@", textField);
}
Related output:
2011-10-30 09:12:08.436 My Project[83470:207] begin edit: <UITextField: 0x6c349d0; frame = (112 2; 182 39); text = 'My Name'; clipsToBounds = YES; opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x6c34af0>>
So I know the textfield frame is there, but when I try to grab it:
code:
- (void)textFieldDidBeginEditing:(UITextField *)textField {
NSLog(@"begin edit: %@", [textField frame]);
// also tried textField.frame -- same thing
}
error:
Thread 1: EXC_BAD_ACCES (code=1, address=0x42e00000)
output:
(lldb)
I've been spinning my wheels on this and I'm not sure where to go next. Thanks for reading my question.
** EDIT - cell xib instantiation (where the textfield lives) **
note: the textfield comes from a xib file that is just a table cell.
static NSString *CellIdentifier = @"ValidatedTextViewTableCell";
ValidatedTextViewTableCell *cell = (ValidatedTextViewTableCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"ValidatedTextViewTableCell" owner:self options:nil];
cell = validatedTextViewTableCell;
self.validatedTextViewTableCell = nil;
}
Upvotes: 1
Views: 1103
Reputation: 71008
This won't work:
NSLog(@"begin edit: %@", [textField frame]);
Because frame
is a CGRect type, not an object, so the %@
format specifier, which is for objects only, blows up when handed it. You'll need to log the frame by each of its components, like this:
NSLog(@"begin edit: %f, %f, %fx%f", [textField frame].origin.x [textField frame].origin.y, [textField frame].size.width, [textField frame].size.height);
Upvotes: 3