I need to change the text of the Cancel button to always display "Reset" in my app. I found many similar questions here on SO, but all answers are for ObjC, while I am working in Monotouch.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
Note that the subview hierarchy is different in ios6 and ios7.
But by adding the extension method below you can use
Extension method that works in ios7 and ios5/ios6:
Use the extension method below for iOS7+ like this: searchBar.SetCancelTitle("close");
It derives from Kolbjørn Bredrup's comment, which is great, but it wasn't clear to me what the namespaces were for the additional extension methods that it uses internally (OfType and FirstOrDefault) so I added them to this class myself.
I also renamed the class UISearchBarExtensions so that it sat nicely with my other ones.
Thanks to Kolbjørn Bredrup for the original!
As with the original, it is called using:
searchBar.SetCancelTitle("close");
It was very easy -