gpt4 book ai didi

iphone - UISearchBar 与 InputView

转载 作者:行者123 更新时间:2023-12-03 19:42:06 36 4
gpt4 key购买 nike

我正在为我的应用程序制作自定义键盘,它与 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 Done button always enabled

关于iphone - UISearchBar 与 InputView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5769999/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com