Xamarin set content view width to root view - uiscrollview

I'm using Xamarin Auto Layouts with Storyboard on Visual Studio 2015.
I have a root view, Scroll View and Content View.
I want the application to only scroll on the y-axis but scale on the x-axis.
I want to do something like this.
Adding a view to a scroll view that will stretch to fill available width
Which is setting the width of the content view to the root view.
But using Xamarin this does not seem possible.
So in this example, if I run the application, I have to scroll to the right to see the right most label. I want all three labels to show up on the iPhone, by scaling down on the x-axis.
I have also tried using the "I" handle on the content view in storyboard UI Designer of Xamarin VS, but it doesn't identify the root view.
If it's not possible using storyboard, I will settle with code.
I have tried this.
public override void ViewDidLoad()
{
ContentView.Frame = new CoreGraphics.CGRect(ContentView.Frame.X, ContentView.Frame.Y, View.Frame.Width, ContentView.Frame.Height);
//ScrollView.TranslatesAutoresizingMaskIntoConstraints = false;
base.ViewDidLoad();
// Perform any additional setup after loading the view, typically from a nib.
}
But it doesn't do anything to help me.
How can I scale the UI down on the X-axis while on top of a scroll view using Xamarin.ios?

Related

Xamarin.Forms MasterDetailPage with part of master visible on detail

I want to push (make visible) little part of master page to detail page like on pictures in links below. Is it possible in Xamarin.Forms?
Before swipe
After swipe
I'll be grateful for help.
Set
<ContentPage NavigationPage.HasNavigationBar="False">
Place a StackLayout or Grid that looks like the side menu shown in your image. Add a tap gesture recognizer to it.
slMenu.GestureRecognizers.Add(new TapGestureRecognizer
{
Command = new Command(() => ShowSideMenu(masterPage)),
});
private void ShowSideMenu(MasterDetailPage masterPage)
{
masterPage.IsPresented = !masterPage.IsPresented;
}
This is possible, but requires quite some work, since you can't access the width of the MasterDetailView directly.
In another post (see How to set width for MasterDetailPage in xamarin forms ) I have described how to change the width of the MasterDetail view.
While implementing that, I came across a behaviour like you want to have, though for me it was an error.
Basically the steps would be
Implement a custom version of the MasterDetail view where you can set up a custom width
Change the width of the master view so it is a bit wider than it should be
Adapt the calculations when collapsing and expanding the view so that they don't collapse the entire width
For instance if your Master View gets a width of 340 and you want the last 40 to show, make sure that when being collapsed it "only" moves by 300

UIScrollView cover controllers on top

I have a problem with an old project (Objective-C and No Auto layout).
I am trying to update some logic but I have a problem with a controller.
The structure of the controller is the same as the image attached
I have the problem that when I scroll up the tableView, the scrollView covers the button container view.
How can I solve this issue? I need that the scrollview does not cover that bar.
did you try to have another viewContainer where you put on the tableView and the Line Color?
Basically you need to have something like that:
View
viewContainer (Table View Container)
tableView
Line Color
viewContainer (Button View Container)
button

Dynamically changed views in a full screen window in Xamain.Mac (monomac)

I am trying to figure out a correct composition of views and subviews in Xamarin.Mac (monomac) application.
There are very little examples of Windows/Background View/Controls UI with Xamarin.Mac out there and those which I found (basically this project is the best documented one when it comes to Window/View composition) suffer from the same problem - its a static binding of a form Window -> Background view (bound in XCode) -> Controls under the View node. What's being displayed as controls on the view isn't dynamically added via C# and not even a separate view inside the background view.
What I need, is to create a Window, that has a background view that will be semitransparent and then have my application dynamically, depending of the app logic, inject different subviews to background view from C# code. I know that one can add a subview to a view in Xamarin.Mac, but when I try it in my case, the subview just isn't being shown:
GoFullscreen is where the window starts to transform:
private void GoFullScreen ()
{
// Set the window level to be above the menu bar
Window.Level = NSWindowLevel.Normal;
var backgroundView = new LeoBreakBackgroundView ();
backgroundView.SetBreakSubview (_currentBreakViewController);
Window.ContentView = backgroundView;
Window.ContentView.EnterFullscreenModeWithOptions (NSScreen.MainScreen, new NSDictionary());
// Show the window
Window.MakeKeyAndOrderFront (this);
}
At the point I call backgroundView.SetBreakSubview (_currentBreakViewController);
which is:
_currentBreakViewController = currentBreakController;
this.AddSubview (_currentBreakViewController.View);
I don't see the _currentBreakViewController.View being added to backgroundView, but the backgroundView is indeed added onto a window that goes fullscreen.
_currentBreakViewController is a NSViewController and LeoBreakBackgroundView you see in the first snippet is just an NSView without a controller.
Anyways, is it possible to control a View's subview dynamically from code in Xamarin.Mac?

Metaio ARViewController with Image View on top in xcode

The Metaio Cloud plugin lets me setup an xcode 5 project (tabbed, two tabs) and set one of the view controllers to have custom class "ARViewController". This makes that view controller utilize the cloud plugin and show the view of the iphones camera for augmented reality.
I would like to overlay my logo onto this custom view controller, so I dragged an image view to the view controller, set the image source, and set the view mode to top. I set the background and tint to clear color, but for some reason I no longer see the camera view - I only see black.
Is there a reason this would either:
1) Make the ARViewController not work? or
2) make the image view black everywhere besides the logo, covering the ARViewController so that it can not be seen?
I ended up solving this issue. I put the ARViewController in a "container view" so the order of my items in storyboard is like this:
View
-Container View (Attach ARViewController to this view)
-Image View (Position on top of container view by clicking
"Editor">"Arrange">"Send to Front")

Xcode - Nested storyboard views - hide/show?

I have a reasonably complicated UIView which contains several nested views which are displayed according to a variety of responses - all are laid out in a storyboard.
Is there a way to hide a view in the foreground to work on a view in the background? As its really fiddly selecting particular elements to arrange / style!?
I've been trying to figure out a nice way to do this, some function like hiding the view and its subviews from the storyboard (not from the actual application), but couldn't find anything.
This is not the nicest of ways but it is how I do it at the moment...
What I do is select the views I want to "hide" from the document outline and add a constant (screen width/height) value to its x/y origin value to push them out of the screen. I also change the document label for those views (Identity Inspector > Document > Label) to something like "Hidden" so I can later search for the "hidden" views from the document outline and put them back where they belong.
I have 2 work arounds.
A) Change the View Controllers size to freeform. Set its size to be really large so I can space out the views.
B) Use the sort order of the views Document Outline (lowest is front most) and add an image view (same as the view background) under the first view to block the others. Then delete it after finishing my edits.
or xcode developers could just simple add a design-visible checkbox for views and controls.... but ill take my rants somewhere else.
In xcode 7 you can do it from the storybord
for more details
https://stackoverflow.com/a/25213491/4879683
Maybe this could help you :
Open your storyboard in the Finder and edit it with a simple text editor (not xcode).
You will see it's just a xml file.Look for the view you want to hide, and add hidden="YES" in the parameters list.
That's what I do on my own project.
In Xcode when you select your storyboard, you have a panel that displays all your view controllers and their hierarchy. If you change the order of the elements you change the background/foreground order.
You can add extra views to the scene dock.
These views get initiated along with the view controller, but are not added to the view controller's view hierarchy. You can reference them using IBOutlets.
e.g. I have a full screen loading view that I added to the scene dock instead of covering up the view controller in the storyboard. I can add the loading view to the view controller's view hierarchy in code:
#IBOutlet weak var loadingView: UIView!
...
loadingView.frame = view.bounds
loadingView.autoresizingMask = UIViewAutoresizing.FlexibleWidth.union(UIViewAutoresizing.FlexibleHeight)
view.addSubview(loadingView)
Reference: https://developer.apple.com/library/ios/recipes/xcode_help-IB_storyboard/Chapters/AddViewsToDock.html

Resources