I have a mobile app in Xamarin Forms 3.2, which works fine on Android, however when I run the build for iOS, it compiles without errors, loads the iOS emulator, and throws the following exception:
Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: -[UISearchBar sizeThatFits:] does not support passing non-finite values ({inf, 56})
Native stack trace:
0 CoreFoundation 0x00000001078cf6fb __exceptionPreprocess + 331
1 libobjc.A.dylib 0x00000001088baac5 objc_exception_throw + 48
2 CoreFoundation 0x00000001078cf482 +[NSException raise:format:arguments:] + 98
3 Foundation 0x00000001071ff927 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 194
4 UIKitCore 0x000000010e1ab6b2 -[UISearchBar sizeThatFits:] + 301
5 marketing_app.iOS 0x00000001039b1399 xamarin_dyn_objc_msgSend + 217
6 ??? 0x000000012eb3f6ae 0x0 + 5078513326
7 ??? 0x000000012eb54987 0x0 + 5078600071
Within the properties, I have the following:
-[UISearchBar sizeThatFits:] does not support passing non-finite values ({inf, 56})
It strikes me that it works well on Android and that it breaks on iOS; Anyway, effects of the learning curve, by the way, this is the XAML that I am using:
<SearchBar Grid.Row="0" Margin="0,20,0,0" Placeholder="Search" SearchCommand="{Binding Path=SearchingCommand}" Text="{Binding Path=SearchQuery}"></SearchBar>
The only thing missing was adding the WidthRequest property
Now it works perfectly!
According to the documentation:
https://docs.microsoft.com/en-us/dotnet/api/xamarin.forms.searchbar?view=xamarin-forms
The WidthRequest property
IN:
IT IS: