Xamarin.forms: [Bug] ImageButton.Aspect Property is always Fill on iOS after update to Xamarin.Forms 4.4.0.991265

Created on 31 Dec 2019  路  32Comments  路  Source: xamarin/Xamarin.Forms

Description

After update to Xamarin.Forms 4.4.0.991265, ImageButton.Aspect Property is always Fill on iOS even if it is set to AspectFit. It worked correctly before I updated to 4.4.0.991265 from 4.3.0.991250. This issue does not occur on Android.

Steps to Reproduce

  1. Create a Page and place a StackLayout which contains some ImageButton.
  2. Set ImageButton.Aspect to AspectFit, or leave it blank (the default value is AspectFit).
  3. Set ImageButton.HorizontalOptions and ImageButton.VerticalOptions to FillAndExpand.
  4. Set ImageButton.Source to any ImageSource.
  5. Run on iOS.

Expected Behavior

Images of ImageButton displays as AspectFit.

Actual Behavior

Images of ImageButton displays as Fill. See Screenshots.

Basic Information

  • Version with issue: 4.4.0.991265
  • Last known good version: 4.3.0.991250
  • IDE: Microsoft Visual Studio Community 2019 Version 16.4.2
  • Platform Target Frameworks:

    • iOS: Default (Perhaps 13.2)

    • Android: Android 10.0 (API Level 29 - Q)

    • UWP: I have not tried

  • Affected Devices: iOS

Screenshots

These screenshots were taken on iPhone 4S - iOS 9.3.6.

Xamarin.Forms 4.4.0.991265 | Xamarin.Forms 4.3.0.991250
------------ | -------------
image-1 | image-2

Reproduction Link

https://gist.github.com/Soushi-Atsumi/0e79c20574f517008f83c1bf1f3aa8f6

imagebutton 2 regression in-progress UWP iOS 馃崕 bug

Most helpful comment

Image works as a workaround, but it's silly to have this bug for such a long time...

All 32 comments

same here. Please fix it

@samhouts This is also the same on UWP too. Shall I create another ticket?

@velocitysystems Thanks for the confirmation! We'll just put the UWP label on here. :)

Image works as a workaround, but it's silly to have this bug for such a long time...

same here.

I'd like to add a workaround whilst waiting for this fix to make it into a Stable build. I assume the workaround is a CustomRenderer that will explicitly set the correct Aspect is iOS?

Any chance this could get fixed? It is really really hard to make apps with Xamarin and to take it seriously, as so many of the most primitive controls are broken. So much time is wasted with "what am I doing wrong?", just to find out that it's another regression.
Thanks.

Any chance this could get fixed? It is really really hard to make apps with Xamarin and to take it seriously, as so many of the most primitive controls are broken. So much time is wasted with "what am I doing wrong?", just to find out that it's another regression.
Thanks.

For now it is better to use a ContentButton like https://gist.github.com/GioviQ/1e73bc6f9df6ddf8f4e52d4ea5c8bac6

Any chance this could get fixed? It is really really hard to make apps with Xamarin and to take it seriously, as so many of the most primitive controls are broken. So much time is wasted with "what am I doing wrong?", just to find out that it's another regression.
Thanks.

For now it is better to use a ContentButton like https://gist.github.com/GioviQ/1e73bc6f9df6ddf8f4e52d4ea5c8bac6

It's not practical to go over all controls and replace them. Is this going to be shipped in vNext and what's the ETA please.

If you look the tree you will see that the fix (https://github.com/xamarin/Xamarin.Forms/pull/9662) was merged today into forms 4.4.0. So it will be shipped in the next Service Release of 4.4.

Posting here to mention the same and follow along. This is preventing us from upgrading to 4.5.... which we need to upgrade to eventually given that Apple will stop allowing app submissions prior to 4.5 (because of the UIWebView issue). Do we know if this will get merged into 4.5?

+1, we definitely need this to be shipped as part of v4.5.

<ContentView Grid.Column="0" Grid.Row="1"> <Button Style="{StaticResource buttonStyle}" Command="{Binding SearchCommand}" /> </ContentView> <StackLayout Margin="25,0,0,0" InputTransparent="True" VerticalOptions="Center" Spacing="15" Orientation="Horizontal" Grid.Column="0" Grid.Row="1"> <Image WidthRequest="38" Source="search_button.png"></Image> <Label Style="{StaticResource textWhite18}" Text="{local:TranslateExtension search}"></Label> </StackLayout>

I would recommend switching for more reliable controls. This is what I used: a label and image and a button all 3 in the same grid/row position

Any ETA for the upcoming service release?

Seeing this problem in Xamarin.Forms v4.5.0.356. Tried older versions and what I saw was the following.

4.4.0.991265 - DOES NOT WORK, IMAGE STRETCHED
4.3.0.991250 - WORKS CORRECTLY

So, as of v4.5.0.356 this was still not fixed.

Seeing this problem in Xamarin.Forms v4.5.0.356. Tried older versions and what I saw was the following.

4.4.0.991265 - DOES NOT WORK, IMAGE STRETCHED
4.3.0.991250 - WORKS CORRECTLY

So, as of v4.5.0.356 this was still not fixed.

The fix has not been released yet. We are waiting for the next service release.

Seeing this problem in Xamarin.Forms v4.5.0.356. Tried older versions and what I saw was the following.
4.4.0.991265 - DOES NOT WORK, IMAGE STRETCHED
4.3.0.991250 - WORKS CORRECTLY
So, as of v4.5.0.356 this was still not fixed.

The fix has not been released yet. We are waiting for the next service release.

Not sure how the release cycle works, but I just tested v4.6.0.379-pre1 and the issue appears to still be present there.

Seeing this problem in Xamarin.Forms v4.5.0.356. Tried older versions and what I saw was the following.
4.4.0.991265 - DOES NOT WORK, IMAGE STRETCHED
4.3.0.991250 - WORKS CORRECTLY
So, as of v4.5.0.356 this was still not fixed.

The fix has not been released yet. We are waiting for the next service release.

Not sure how the release cycle works, but I just tested v4.6.0.379-pre1 and the issue appears to still be present there.

Same here...

closed by #9662. This should be fixed in 4.4.0 sr6, 4.5.0.495 (sr2), and 4.6.0-pre2. Thanks!

closed by #9662. This should be fixed in 4.4.0 sr6, 4.5.0.495 (sr2), and 4.6.0-pre2. Thanks!

I verified this is in fact NOT fixed in 4.5.0.495 or the pre-release for 4.6.0. Note the stretched images highlighted in yellow.

image

@eekamouse can you attach a repro?

I tested with @samhouts zip here
https://github.com/xamarin/Xamarin.Forms/issues/9054#issuecomment-570009538

And I'm able to see the issue and then I update and the issue goes away

<NavigationPage.TitleView> <Grid Margin="10" HorizontalOptions="FillAndExpand" AutomationId="HomeGrid" AutomationProperties.IsInAccessibleTree="True"> <Grid.ColumnDefinitions> <ColumnDefinition Width="48"/> <ColumnDefinition Width="*"/> <ColumnDefinition Width="48"/> </Grid.ColumnDefinitions> <ImageButton Command="{Binding CancelCommand}" Source="{local:Resource Source='back_icon'}" Style="{StaticResource TitleButton}" AutomationId="Cancel" AutomationProperties.IsInAccessibleTree="True"/> <Label Grid.Column="1" Text="{Binding Title}" Style="{StaticResource TitleLabel}" AutomationId="ProgramPageTitle" AutomationProperties.IsInAccessibleTree="True"> <Label.GestureRecognizers> <TapGestureRecognizer Command="{Binding TitleTappedCommand}"/> </Label.GestureRecognizers> </Label> <ImageButton Grid.Column="2" Command="{Binding BarCodeOpenCommand}" Source="{local:Resource Source='barcode_scan_icon_white'}" Style="{StaticResource ScanButton}"/> </Grid> </NavigationPage.TitleView>

Sorry the above isn't better formatted, but I have multiple examples like that where we have images in a TitleView that are skewed that look fine on UWP and Android... and were working on iOS on Xamarin 4.3.

if you want to fix this bug temporary, you can play with the padding property on the iOS platform.
Padding="0":
image

Padding="15", still not perfect but:
image

Padding="13,15,13,15", finally, very close to the original image:
image

Anyway, we have to use padding to increase the touching zone (for small buttons).

I messed around with padding today and it doesn't seem to do anything but make it worse (and make it look funky on Android and UWP). It might be because our images are in a TitleView.

I updated and tested today with XF 4.4.0.991864. It's working fine.

I updated and tested today with XF 4.4.0.991864. It's working fine.

I had tested v4.5.0.356 and it did not work in that version.

I updated and tested today with XF 4.4.0.991864. It's working fine.

I had tested v4.5.0.356 and it did not work in that version.

Not tested with 4.5, but it's strange. Xamarin must work on the stability of their releases.

I have tested v4.5.0.617 and it works fine.

I can confirm it works on 4.5.0.617.

Was this page helpful?
0 / 5 - 0 ratings