Open PureWeen opened 4 years ago
Ok, the crash itself is iOS complaining about use of undocumented views.
However, trying to do it correct appears to hit a bug with our Appearance APIs. I can confirm the weirdness you are seeing.
This ugly code should work for you as a workaround:
[System.Runtime.InteropServices.DllImport ("/usr/lib/libobjc.dylib", EntryPoint = "objc_msgSend")]
public extern static void void_objc_msgSend_IntPtr (IntPtr receiver, IntPtr selector, IntPtr arg1);
var app = UIBarButtonItem.AppearanceWhenContainedIn (typeof (UISearchBar));
using (var title = new NSString ("Cancel"))
void_objc_msgSend_IntPtr (app.Handle, ObjCRuntime.Selector.GetHandle ("setTitle:"), title.Handle);
app.TintColor = UIColor.Red;
Included project is just Xamarin.iOS so moved issues from here https://github.com/xamarin/Xamarin.Forms/issues/7785
Summary
When developing a mobile application using Xamarin.iOS and now i've just updated the Xamarin's latest version, to have compatiblity with the new iOS 13. So far i was changing the text of the UISearchBar cancel button using
SetValueForKey
but now it tells me thativar is prohibited. This is an application bug.
API Changes
From IOS 13 ,
SetValueForKey
method useing key with_cancelButtonText
can not work in VS and Xcode. However , xcode has another way to realize it before IOS 9.0:[[UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil] setTitle:@"Cancel"]
After IOS 9.0 has the follow way :[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class]]].title = @"Cancel";
Unfortunately , they all not found in VS .
e.g.
MySearchBar.SetShowsCancelButton(true, true);
MySearchBar.SetValueForKey(new NSString("Click"), new NSString("_cancelButtonText"));
And only can set
TintColor
:UIBarButtonItem.AppearanceWhenContainedIn(typeof(UISearchBar)).TintColor = UIColor.Red;
Not found propertyText
orTitle
the same as Xcode.Intended Use Case
So link : https://stackoverflow.com/questions/58188633/xamarin-problems-with-uisearchbars-cancel-button-in-ios-13
Sample-Link: https://www.dropbox.com/s/3rmksed1jn3nfmj/AppIOSFour.rar?dl=0