UITextView delegate inconsistency...
Hello,
I've figured this out, read for fun only!
I am implementing high score functionality and having some strange trouble with my UITextView. The delegate receives the beginEditing notification but nothing else. Initially, beginEditing was not invoked, but then I moved my call to -setDelegate: to after when it was added as a subview, as adding a subview apparently modifies a control's delegate...
Code below:
When viewing the console, "mmm" is displayed as expected. But nothing occurs when I hit return. Perhaps hitting return doesn't automatically send a didEndEditing notification?
I'd appreciate any advice, and I'll keep you posted if I come across the solution.
Thanks,
- Dave H.
I've figured this out, read for fun only!
I am implementing high score functionality and having some strange trouble with my UITextView. The delegate receives the beginEditing notification but nothing else. Initially, beginEditing was not invoked, but then I moved my call to -setDelegate: to after when it was added as a subview, as adding a subview apparently modifies a control's delegate...
Code below:
Code:
@implementation GameStateHighScores
-(id) initWithScore:(GLfloat)_score {
self = [super init];
if (self) {
theScore = _score;
playerNameField = [[[UITextField alloc] initWithFrame:PlayerNameFieldFrame] autorelease];
[playerNameField setBackgroundColor:[UIColor whiteColor]];
[playerNameField setFont:[UIFont systemFontOfSize:24.0f]];
[playerNameField setTextAlignment:UITextAlignmentCenter];
[playerNameField setKeyboardAppearance:UIKeyboardAppearanceAlert];
[[GameView sharedView] addSubview:playerNameField];
[playerNameField setDelegate:self];
[playerNameField becomeFirstResponder];
}
return self;
}
+(id) highScoresStateWithScore:(GLfloat)_score {
return [[[self alloc] initWithScore:_score] autorelease];
}
-(void) textFieldDidBeginEditing:(UITextField *)textField {
NSLog(@"mmm.");
}
-(BOOL) textFieldShouldEndEditing:(UITextField *)textField {
return YES;
}
-(void) textFieldDidEndEditing:(UITextField *)textField {
NSLog([textField text]);
}
@endWhen viewing the console, "mmm" is displayed as expected. But nothing occurs when I hit return. Perhaps hitting return doesn't automatically send a didEndEditing notification?
I'd appreciate any advice, and I'll keep you posted if I come across the solution.
Thanks,
- Dave H.
the method I was looking for was
-(BOOL) textFieldShouldReturn:(UITextField *)textField
Blah
-(BOOL) textFieldShouldReturn:(UITextField *)textField
Blah
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| What should I use, subclassing or delegate (opengl es)? | riruilo | 2 | 2,122 |
Dec 18, 2008 08:43 PM Last Post: AnotherJake |
|

