Bug 28388 - NavigationRenderer.ParentingViewController (still) breaks things
Summary: NavigationRenderer.ParentingViewController (still) breaks things
Status: RESOLVED NOT_ON_ROADMAP
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms (show other bugs)
Version: 1.4.0
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-03-24 18:12 UTC by Adam Kemp
Modified: 2018-01-09 20:09 UTC (History)
11 users (show)

Tags: ios customrenderer ac
Is this bug a regression?: ---
Last known good build:


Attachments
Test case (4.12 MB, application/zip)
2015-03-24 18:12 UTC, Adam Kemp
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NOT_ON_ROADMAP

Description Adam Kemp 2015-03-24 18:12:11 UTC
Created attachment 10482 [details]
Test case

This is a redux of this: https://bugzilla.xamarin.com/show_bug.cgi?id=24484

I have a custom page renderer with this code:

        public TestPageRenderer()
        {
            NavigationItem.TitleView = new UISegmentedControl(new[] { "A", "B" });
            NavigationItem.TitleView.SizeToFit();
        }

That should cause a segmented control to appear in the navigation bar in place of the title. This doesn't work. The reason is that the parenting controller is not reflecting the properties in the wrapped page view controller.

The workaround that we should never have to do is this:

        public override void WillMoveToParentViewController(UIKit.UIViewController parent)
        {
            base.WillMoveToParentViewController(parent);

            if (parent != null)
            {
                parent.NavigationItem.TitleView = NavigationItem.TitleView;
            }
        }

That's not our job. It's your job. Automatic wrappers should be transparent. Your wrapper interferes with the abstraction and requires that implementers of custom page renderers understand the private implementation of Xamarin.Forms.

To reproduce this issue run the attached project. You should see a segmented control in the title bar.
Comment 1 Rajneesh Kumar 2015-03-25 06:39:35 UTC
I have checked this issue and able to reproduce this. To reproduce this issue I have followed the instruction in bug description.

Steps I followed:

1.  Open attached test sample in XS.
2.  Set Android/iOS as startup project.
3. Deploy it on Emulator/Simulator.
4. Observed that a segmented control in the title bar in place of the title.

Screencast: http://www.screencast.com/t/Ie9Xvq42LYVb

Ide Logs: https://gist.github.com/Rajneesh360Logica/9c13c3b2db7e53aef74c
Build Output: https://gist.github.com/Rajneesh360Logica/26447c4330a999fbbdb7

Environment Info:

=== Xamarin Studio ===

Version 5.9 (build 300)
Installation UUID: 011d70a5-dede-428b-ab04-ef451c2e539d
Runtime:
	Mono 4.0.0 ((detached/c52336f)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400000093

=== Apple Developer Tools ===

Xcode 6.2 (6776)
Build 6C131e

=== Xamarin.iOS ===

Version: 8.10.0.149 (Business Edition)
Hash: 012108b
Branch: master
Build date: 2015-03-24 03:03:50-0400

=== Xamarin.Android ===

Version: 4.20.0.37 (Business Edition)
Android SDK: /Users/MM/Desktop/android-sdk-macosx
	Supported Android versions:
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 2.0.0.149 (Business Edition)

=== Build Information ===

Release ID: 509000300
Git revision: 70297cc38ddc396b097fe2cc3e805718b78efdeb
Build date: 2015-03-24 06:32:51-04
Xamarin addins: fad66559ea5a308dacec9e5fdd1578c909d97688

=== Operating System ===

Mac OS X 10.9.5
Darwin MacMini.local 13.4.0 Darwin Kernel Version 13.4.0
    Sun Aug 17 19:50:11 PDT 2014
    root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64
Comment 2 Chris King 2015-05-27 18:59:03 UTC
Thank you for submitting this issue. Is there an enhancement we can make to Forms so that you won't need to create a custom renderer? We will work to fix this issue. That said, we will be able to provide a more stable platform and resolution if we're able to add functionality to the core so you no longer have to produce the custom render. 

Warm regards,
Xamarin Forms Team
Comment 3 Adam Kemp 2015-05-29 12:23:50 UTC
There's one example in the original report, but here are a few other common use cases:

1. Changing the modal presentation. For instance, maybe I want a FormSheet presentation or a custom animation.
2. Manipulation of the toolbar. Similar to the title view example above, maybe I need a custom control like a segmented control in the toolbar as an item (on the right or left).
3. Change the allowed orientations for a given page.
4. Change the status bar appearance for a given page.

In general I would say you're never going to _entirely_ get rid of the need for custom page renderers, and for those cases where people do end up needing to tweak something the current implementation (with these wrapper view controllers) interferes and sometimes makes it impossible to do what you want to do (for example, in use cases 3 and 4 above).
Comment 4 Jason Smith [MSFT] 2016-04-08 19:23:24 UTC
Thank you for your report. At this time there are no plans to implement any changes around this issue.

Warm regards,
Xamarin Forms Team
Comment 5 marco.mader 2017-02-07 08:44:20 UTC
This is still a bug.

The ticket shouldn't be resolved I think
Comment 6 Richard 2018-01-09 20:09:44 UTC
Come on Xamarin, please consider resolving this and making life a bit easier for developers using customer renderers.