Xamarin.Forms icon indicating copy to clipboard operation
Xamarin.Forms copied to clipboard

[Bug] [iOS] Hiding Shell TabBar does not force re-layouting of the page

Open TimLandskron opened this issue 4 years ago • 5 comments

Description

The page is loaded completely and appeared on the screen already. The user clicks a button which results in hiding the TabBar via Shell.SetTabBarIsVisible = false. The page does not force a new layout cycle because the content now should have more space. On Android, this works perfectly. I have found this bug while implementing an action sheet that pops up from the bottom. The action sheet is hiding the TabBar while being shown, but every control which is "laying above" the TabBar is not interactable by the user (e.g. button clicks, gesture recognizers). A ForceLayout() call after setting the TabBarIsVisible property did not work (also with a Task.Delay(1000)).

Steps to Reproduce

  1. Build & deploy the attached Xamarin.Forms app.
  2. Switch to the "Browse" tab
  3. Open any ItemDetailPage by clicking one of the six items in the list.
  4. Click on the "Hide TabBar" button

Expected Behavior

The label which is positioned at the bottom of the screen should update its position. For the expected behavior, the android app can be run.

Actual Behavior

The label does not update its position.

Basic Information

  • Version with issue:
  • Last known good version:
  • Platform Target Frameworks:
    • iOS: 14.5

Environment

Show/Hide Visual Studio info
=== Visual Studio Enterprise 2019 for Mac ===

Version 8.10.6 (build 10)
Installation UUID: af002a60-ada6-489b-acf2-af11994d1a96
	GTK+ 2.24.23 (Raleigh theme)
	Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)

	Package version: 612000140

=== Mono Framework MDK ===

Runtime:
	Mono 6.12.0.140 (2020-02/51d876a041e) (64-bit)
	Package version: 612000140

=== Roslyn (Language Service) ===

3.10.0-4.21269.26+029847714208ebe49668667c60ea5b0a294e0fcb

=== NuGet ===

Version: 5.9.0.7134

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/5.0.302/Sdks
SDK Versions:
	5.0.302
	5.0.203
	5.0.202
	5.0.201
	3.1.411
	3.1.409
	3.1.408
	3.1.407
MSBuild SDKs: /Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
	5.0.8
	5.0.6
	5.0.5
	5.0.4
	3.1.17
	3.1.15
	3.1.14
	3.1.13

=== .NET Core 3.1 SDK ===

SDK: 3.1.411

=== Xamarin.Profiler ===

Version: 1.6.15.68
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Xamarin.Android ===

Version: 11.3.0.4 (Visual Studio Enterprise)
Commit: xamarin-android/d16-10/ae14caf
Android SDK: /Users/timlandskron/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		None installed

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 30.0.4
SDK Build Tools Version: 30.0.2

Build Information: 
Mono: b4a3858
Java.Interop: xamarin/java.interop/d16-10@f39db25
ProGuard: Guardsquare/proguard/v7.0.1@912d149
SQLite: xamarin/sqlite/3.35.4@85460d3
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-10@c5732a0

=== Microsoft OpenJDK for Mobile ===

Java SDK: /Users/timlandskron/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 16.10.0.12
Hash: e240b8c
Branch: remotes/origin/d16-10
Build date: 2021-06-01 18:26:34 UTC

=== Android Device Manager ===

Version: 16.10.0.14
Hash: e340248
Branch: remotes/origin/d16-10
Build date: 2021-06-01 18:26:52 UTC

=== Xamarin Designer ===

Version: 16.10.0.119
Hash: 36a2d986f
Branch: remotes/origin/d16-10
Build date: 2021-06-02 19:41:34 UTC

=== Apple Developer Tools ===

Xcode 12.5.1 (18212)
Build 12E507

=== Xamarin.Mac ===

Xamarin.Mac not installed. Can't find /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version.

=== Xamarin.iOS ===

Version: 14.20.0.24 (Visual Studio Enterprise)
Hash: c4b89cddb
Branch: d16-10
Build date: 2021-06-15 22:03:01-0400

=== Build Information ===

Release ID: 810060010
Git revision: 263d2fc9398e8092c231fa5d310cd72205cd627c
Build date: 2021-07-08 14:37:29-04
Build branch: release-8.10

=== Operating System ===

Mac OS X 10.16.0
Darwin 20.6.0 Darwin Kernel Version 20.6.0
    Wed Jun 23 00:26:31 PDT 2021
    root:xnu-7195.141.2~5/RELEASE_X86_64 x86_64

=== Enabled user installed extensions ===

DeepClean 1.2.5


Screenshots

Actual behavior: Screenshot 2021-08-02 at 14 34 16

Expected behavior: Screenshot 2021-08-02 at 14 34 43

TabBar area is not interactable by the user: Screenshot 2021-08-02 at 14 37 10

Reproduction Link

ShellTabBarIssueOniOS.zip

Workaround

Not known yet.

TimLandskron avatar Aug 02 '21 12:08 TimLandskron

I just noticed that when you hide the tab bar in your sample project, move the app to the background and then foreground it again, the layout is updated and looks as expected. The same applies when the tab bar is subsequently being shown again.

The issue may be related to the safe area not being updated when the tab bar is hidden. See this (unfortunately unsolved) issue on SO.

raginmari avatar Aug 12 '21 08:08 raginmari

A workaround that fixes the problem for us (both on native iOS and XF) is this:

var currentFrame = View.Frame; View.Frame = currentFrame.Inset(0, 1); View.Frame = currentFrame;

where View is the view of the UITabBarController whose tab bar is hidden or shown. The above code is executed immediately after the tab bar visibility is changed. The code triggers an update of the safe area and a single layout pass as far as I can see. The resizing of the Frame is not visible to the user.

raginmari avatar Aug 17 '21 07:08 raginmari

@TimLandskron @raginmari would you be able to test the latest version of Forms and see if it is resolved there? Thanks!

jfversluis avatar Nov 15 '21 21:11 jfversluis

@raginimari Hey, at which point can you check when this property has changed? I've tried looking at the property changes in my custom ShellRenderer, ShellItemRenderer and ShellSectionRenderer.

InternationalTyres avatar Mar 31 '22 09:03 InternationalTyres

Hi! We have any workaround about this problem ? I'm currently writing the app those must have a tab bar hiding feature.

@raginmari tells about workaround but I can't understand about that ( can you explain more ? )

MichalPeterek avatar Jul 02 '22 10:07 MichalPeterek