开发者

inputAccessoryView from UISearchBar

开发者 https://www.devze.com 2023-03-04 03:13 出处:网络
How c开发者_开发知识库an I access to inputAccessoryView propery from UISearchBar? I mean there\'s no UITextField property in UISearchBar that by it I couldaccess to inputAccessoryView.

How c开发者_开发知识库an I access to inputAccessoryView propery from UISearchBar? I mean there's no UITextField property in UISearchBar that by it I could access to inputAccessoryView.

Regards


You can cheat a little here, though I think iOS 6 makes this assignable now. Anyway something like this:

for (UIView* v in _mySearchBar.subviews) {
    if ([v isKindOfClass:[UITextField class]]) {
        ((UITextField*)v).inputAccessoryView = _inputToolbarAccessory;
    }
}

Things like this can be dangerous if Apple changes the way they designed that particular widget, but I find myself doing it more often than I probably should.

0

精彩评论

暂无评论...
验证码 换一张
取 消