我是新的IOS
&我正在使用IOS 6
。我的代码中有多个文本字段,其中一个使用数字键盘键盘,我想将自定义按钮添加到它。添加自定义按钮到数字键盘的键盘ios 6
我使用这个代码:
UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
doneButton.frame = CGRectMake(0, 163, 106, 53);
doneButton.adjustsImageWhenHighlighted = NO;
[doneButton setImage:[UIImage imageNamed:@"DoneUp.png"] forState:UIControlStateNormal];
[doneButton setImage:[UIImage imageNamed:@"DoneDown.png"] forState:UIControlStateHighlighted];
[doneButton addTarget:self action:@selector(doneButton:) forControlEvents:UIControlEventTouchUpInside];
// locate keyboard view
UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
UIView* keyboard;
for(int i=0; i<[tempWindow.subviews count]; i++) {
keyboard = [tempWindow.subviews objectAtIndex:i];
// keyboard view found; add the custom button to it
if([[keyboard description] hasPrefix:@"<UIPeripheralHost"] == TRUE)
[keyboard addSubview:doneButton];
}
选择是所谓的,但问题是,[[tempwindow.subviews]count]
为0
谁能帮助我?
在此先感谢。
我会建议使用[InputAccessoryView(http://stackoverflow.com/a/11211721/593709) –