When using a SearchBarDisplay, how to change name of the cancel button

340 views Asked by At

When setting a SearchBarDisplay, using IB or programmatically it gets a Cancel button right to the search window. The text on the button says "Cancel". How do I change text to another language. I know how to change text for a Done button at the Navbar using only SearchWindow but that does not seem to work for this button which comes as default.

And a similar question is the text "No result" coming up in the table if no match. How change to another language?

1

There are 1 answers

10
Prashant Bhayani On BEST ANSWER

You can change title of you cancel but of searchBar by this :

for (UIButton *v in srchBar.subviews) 
{
    NSLog(@"%@",v);

    if ([v isKindOfClass:[UIButton class]])
    {
        [v setTitle:@"Hello" forState:UIControlStateNormal];
    }
}

now set this title as per your language.

i tried this and its working in my demo app.

let me know if it wont work for you.