Reputation: 1125
I have extended UITextField
so that I can use my custom myInputView
. But I am having trouble positioning the myInputView
to a desire location. Doesn't matter what i do to set the CGRect frame of myInputView
it will position the height be at the bottom of the screen.
See Screenshot:
As you can see in the picture the reversed number pad is my custom inputView
, but I want to be able to position it towards the middle of the screen.
MyTextField.h
@interface MyTextField : UITextField {
UIView *myInputView;
}
@property (nonatomic, retain) IBOutlet UIView *myInputView;
@end
MyTextField.m
@implementation MyTextField
@synthesize myInputView;
- (UIView *)inputView {
NSLog(@"Return inputView");
CGRect frame = CGRectMake(0, 200, 320, 215);
[myInputView setFrame:frame];
return myInputView;
}
- (void)dealloc {
[super dealloc];
[myInputView release];
}
@end
Upvotes: 0
Views: 1136
Reputation: 14427
You might want to consider NOT implementing this in terms of an input view. Setting the input view lets the system treat it like it treats the keyboard. You DON'T get to set the frame, only the height. I would recommend getting rid of the UITextField
, and replacing it with a UILabel
with a UIButton
over it. Add your custom input view to the main view, and position it offscreen. When the button is pressed, animate your custom input view back on screen. When the user makes inputs, just update the label. Don't worry about first responder or the UITextField.inputView
at all.
Upvotes: 2