Is there a way to have the Detail page use only ~60% of the device width when the Master is shown and 100% if it is not shown?
Until now I used MasterBehavior = MasterBehavior.Split
. This means that both Master and Detail are always visible. The Master is about 40% wide (in portrait) and the Detail only gets 60%. The Master can neither be swiped away by the user nor can it be hidden programmatically.
When I use MasterBehavior.Default
or Popover
, then the Master page can be swiped in and out. The problem is, that the Detail page is always 100% wide and it is overlapped by the Master page. I want the width of the Detail page to vary depending if the Master is shown or not.
If this cannot be done in Xamarin.Forms, I would also be happy if somebody can suggest how to do it in a custom renderer.
@MichaelRumpler
long story short, it's tricky.
Even on native without Xamarin Forms, changing the master view width on a UISplitViewController is not easy because the properties for changing it are only available with iOS8.
For iOS7 it's tricky, people are calling private methods or subclass UISplitViewController and layout the views in viewDidLayoutSubviews.
Now, with XF, there's more work. If you just want to support iOS8, you could derive from TabletMasterDetailRenderer, and just call those properties for iOS8. For iOS7, you would have to do the same thing as in native.
Hope this helps or answers your question
@MichaelRumpler
googling a bit you gonna find different solutions, here's what I get first
http://stackoverflow.com/questions/2949067/change-the-width-of-master-in-uisplitviewcontroller
and these are the properties
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UISplitViewController_class/#//apple_ref/occ/instp/UISplitViewController/maximumPrimaryColumnWidth
Answers
@MichaelRumpler
long story short, it's tricky.
Even on native without Xamarin Forms, changing the master view width on a UISplitViewController is not easy because the properties for changing it are only available with iOS8.
For iOS7 it's tricky, people are calling private methods or subclass UISplitViewController and layout the views in viewDidLayoutSubviews.
Now, with XF, there's more work. If you just want to support iOS8, you could derive from TabletMasterDetailRenderer, and just call those properties for iOS8. For iOS7, you would have to do the same thing as in native.
Hope this helps or answers your question
I edited my answer.
Thanks @AndreiNitescu
Could you reference something where this is explained? Which properties are you talking about?
But keep in mind, I don't want to change the width of the Master, but only the Detail.
As it happens, I already do subclass the TabletMasterDetailRenderer, so I could just add some more there.
@MichaelRumpler
googling a bit you gonna find different solutions, here's what I get first
http://stackoverflow.com/questions/2949067/change-the-width-of-master-in-uisplitviewcontroller
and these are the properties
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UISplitViewController_class/#//apple_ref/occ/instp/UISplitViewController/maximumPrimaryColumnWidth
@MichaelRumpler I'm thinking that you could dynamically switch from popover to side by side when master is visible. but you need to make master disappear on swipe like in popover mode
@MichaelRumpler I wonder how difficult would it be to use MGSplitViewController instead. It allows you to change widths easily
I'll see how far I'll come with jrc's answer on SO and the maximumPrimaryColumnWidth. If that won't work, I'll have a look at the MGSplitViewController too. I'll let you know.
Thank you!
I got it working, but with a limitation due to a bug in Xamarin.Forms. Here is my complete TabletMasterDetailRenderer:
The problem is, that the
IsPresentedChanged
event is not always raised. When the Master is visible and you rotate your device, then it is not raised anymore. I created bug 30353 for that.I tried using the Master.
Appearing
/Disappearing
events instead, but they are also not raised anymore after the bug explained above got triggered. Moreover they are only raised after the Master slided in/out, but I need to start the animation for the Detail position when it starts.@ChrisKing from Xamarin already confirmed the bug, but he didn't change the status yet.
@AndreiNitescu I just recognized some new problems which came up after I changed the MasterBehavior from Split to Popover. Whenever I tap something on the Detail page, the Master will be scrolled off. There is also always a "Navigation" link at the top left of the Detail page, even though the Master is visible. Both are not desired of course.
Will I have to make the whole TabletMasterDetailRenderer new without inheriting from the existing?