我正在为我的应用程序制作自定义键盘,它与 UITextField 配合得很好。但 UISearchBar 不支持 inputView
- (UIView *)inputView {
if(self.keyboard==nil)
{
self.keyboard=[[[MMKeyboard alloc] initWithNibName:@"MMKeyboard" bundle:nil]autorelease];
}
NSLog(@"HERE");
return self.keyboard.view;
}
如何替换 UISearchBar 中的自定义 UITextField 或如何在 UISearchBar 中实现 inputView ?
正如此代码所做的那样,但您改为更改inputView
:
// loop around subviews of UISearchBar
for (UIView *searchBarSubview in [searchBar subviews]) {
if ([searchBarSubview conformsToProtocol:@protocol(UITextInputTraits)]) {
@try {
// set style of keyboard
[(UITextField *)searchBarSubview setKeyboardAppearance:UIKeyboardAppearanceAlert];
// always force return key to be enabled
[(UITextField *)searchBarSubview setEnablesReturnKeyAutomatically:NO];
}
@catch (NSException * e) {
// ignore exception
}
}
}
请参阅这篇文章了解更多详细信息:
iphone UISearchBar 完成按钮始终启用 https://stackoverflow.com/questions/4728338/iphone-uisearchbar-done-button-always-enabled
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)