inputAccessoryView里的uitextview或者uitextfield怎么获取焦点
1个回答
展开全部
在ios开发中有时候想让文本框获得焦点的时候弹出的不是键盘而是自定义的东西,这个可以通过改变textfield或者textview的inputView来设置;但是要是想在普通键盘上面加一个自定义的view可以通过改变textfield或者textview的inputAccessoryView属性来设置。例如:
oc代码
01 - (void)viewDidLoad
02 {
03 [super viewDidLoad];
04 // Do any additional setup after loading the view, typically from a nib.
05 [self keyboardview];
06 }
07
08 #pragma mark - 键盘上的view
09 -(void)keyboardview
10 {
11 UIView *inputview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 20)];
12 inputview.backgroundColor = [UIColor blueColor];
oc代码
01 - (void)viewDidLoad
02 {
03 [super viewDidLoad];
04 // Do any additional setup after loading the view, typically from a nib.
05 [self keyboardview];
06 }
07
08 #pragma mark - 键盘上的view
09 -(void)keyboardview
10 {
11 UIView *inputview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 20)];
12 inputview.backgroundColor = [UIColor blueColor];
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询