Xamarin.iOS dynamically ScrollView - xamarin

I really need your help.
I'm new at developing Xamarin.iOS apps and now I'm totally stuck.
I cannot get the hang of how to implement a dynamic ScrollView in iOS, it was fairly easy to implement on Android.
So what I'm trying to implement is a view that contains mostly text (that will be quite long, hence the scrolling, but also two buttons.
Here is a gif in Android showing what I'm trying to achieve
The view is like this:
Header
Long text
Copyright button
-- Copyright text
Terms of usage button
-- Terms of usage text
I have struggled with the scrolling so long and I really need your help.
All of the text properties are getting bound to the view by binding with MvvmCross so the view can't be with hard-coded heights and widths, it needs to adjust properly.
Can somebody please show me with a sample project how to implement it?
The view needs to be in a .xib view (because of MvvmCross) and it cannot contain a UIViewcontroller.
So the solution needs to be in a simple UIView
I'm working on a Windows, with Visual Studio 2015 enterprise, and I cannot use a Mac (and Xcode) other than to compile my code with.
What I've tried is a solution like this:
UIView called "MyRootview"
-- UIScrollView called "MyScrollView"
-- -- UIView called "MyContentView"
Can you please help me?

Method 1:
Use a TableView instead of ScrollView. Make the header row 1, long text row 2, button 1 and it's text row 3 and button 4 and it's text row 4.
Give row height for the last 2 rows so that you only see the button and on button click increase the row height and reload the table section.
Method 2:
If you keep wanna using ScrollView, put the button data in a label and give it a height of 0 (and number of lines 1) to hide it and on button click remove the height constraint and set the number of lines to 0 (max).

I used FluentLayout instead. Very easy.
https://github.com/FluentLayout/Cirrious.FluentLayout

Related

Build a Cocoa UI for OSX

I'm trying to build a UI which look like this:
I'm using a storyboard with Xcode but I don't know how to start. I think a need different view in the window to manage button, text and tree but I don't know I to do it. I have try to use a split view but it gave me only 2 views instead of 3.
Any help in Cocoa and storyboard is welcome.
Thanks
Can't see where you'd want to use an NSSplitView but the UI you're attemting to create is trivial -
A plain NSWindow with the toolbar items configured as per your screenshot.
An NSOutlineView for the tree view with the three columns,
the content border of the window sized accordingly to make room for the label you intend to put at the bottom of the window.
As mentioned in the comments one way to populate the outline view would be to use an NSTreeController and Cocoa bindings. That's probably the only slightly more complicated bit about this UI..

Xcode auto layout buttons not resizing

I have looked at many tutorials and just can't seem to get Buttons to resize and layout properly using Xcode 6 auto layout.
The tutorials that make the most sense just use Views as examples.
Trying to build a Universal soundboard app with buttons arranged in the attached picture.
I also tried putting all the buttons in one View container but still no luck.
What am i missing?
Thanks so much
Select the button you want the constraint on, and command click it's parent view.
Next, select add new constraint (at the bottom of xcode), click "Equal Widths", then click add constraint.
Select the object.
Double-click on the constraint rectangle (not obvious! "Edit" takes you somewhere else)
Then at the right hand side of xcode the attribute inspector should
come up:
At the multiplier property you can make a ratio or a decimal of the percentage value you want. If you want the button to be one fourth of it's parent view, then set the multiplier to 1:4.
This might not be the most ideal answer, but it's the best I can offer. Hope this helps!! Good luck!
You can check out this
How to create equal spacing between multiple label in ios xcode 6.3 using AutoLayout Constraints
You can also check out Evenly Spacing Views in Auto Layout
If you still have problem then comment me I will try to fix your issue

Static UITableView not showing cells with subviews (UIButton, UISlider etc.) in Content View

I've run into a peculiar problem with Xcode. I have a custom UITableViewController that appears as a popover for a few settings in an iPad app. It's a static table view with just 3 cells in 2 sections. It looks fine in the Storyboard editor, but at runtime the cells with custom views (UILabels, UISlider, UIButton) do not show up at all, but those custom views do (in random places).
When I delete the custom elements from the cell or change the cell to anything but custom then they show up fine, even if the view (like basic for example) contains a label in its Content View. It's a lot clearer to see with the attached picture.
To solve this, I've created a completely empty cell below those with custom elements. It looks fine, but I can't interact with any elements. User Interaction is enabled for all elements, cells, and the entire table view. If you have any ideas how to solve that or how to get the cells working properly so I don't need the blank cell hack that'd be much appreciated!
I'm using Xcode 6 beta 7 on OS X Yosemite, programming in Swift.
Thanks in advance!
The question has been answered here Stack Overflow Setting up Auto Layout connections from the label to the Content View solves this issue.
It was a combination of the above link as well as this one that finally solved it.
I added the 4 constraints from each object (UIButton and UISlider) to all four sides of its cell's Content View (top, bottom, leading, trailing). Then, I had to check the "installed" checkbox for each constraint, which was not checked.
Thank you so much for your help, it's working great now!

Overlapping cells in static tableview built using storyboard

All,
I'm using the Xcode 6 beta to build an iOS8 project using storyboard and swift. In the storyboard, I've created a Table View Controller as my primary view when the application loads and have added a label to the first cell and a label to the second cell.
The table looks fine in the storyboard, but when I run the application, the cells overlap. This is a brand new project with no other changes made or code added.
You can see both the storyboard and the running application in the photo below. Any ideas on what could be driving this?
Additionally, when I try to add a button to one of the cells, I get a grey box that covers 90% of the view.
I think I've had this issue. Try making some Auto Layout connections from the label to the Content View of the cell, and from the table view (and its cells) to the containing view, to force the views to be the proper size.
The following worked for me.
Control-click and drag from your label to left side of the cell it's in. When the modal comes up, check the box for 'Leading Space to Container'.
Repeat the same Control-click and drag process for each side of the cell, selecting the relevant Auto Layout option when it appears.
(Optional) Try to Control-click and drag from your table view to the each side of the containing view (if there is one), and repeat the steps from above.
Hopefully this works for you.

UITableview bottom is cut off on iphone5

Let me preface this by saying this works perfectly on the iphone 4 - retina and regular.
I have a grouped table that has 4 sections. to set it up i use the dispatch_async stuff in viewWillAppear to grab the information from a server - and then call reloadTable when the server returns.
after the table has been reloaded with the correct information, when i try and scroll down i see more cells but it gives resistance as if i had already reached the end of the table even though there are 3 or 4 more table cells to show and bounces back.
there is one cell that has an image and some text that i use cell.addsubview to add some subviews to it in the cellForRowAtIndexPath function.
but all the other cell heights are normal (44)
I am using IB to have the grouped table view and don't set the frame,bounds, or anything with it in my code - just set the various tablecell heights using the correct function.
does anyone know why it would work perfectly in the iphone 4 (i can scroll down to the bottom and see all the cells) and not in the iphone 5?
Thank you.
I had autolayout checked in the Xib files.
To fix the problem i set self.view.frame.size.height to 568 in the top view controller (i was using a navigation conroller that loaded table views). once i did that, all the child views worked correctly.
I have same problem to fix like below optimized way
if your using autoLayout don't be hardcode just use constraints
i don't know how to use XIB but i always use like this
tableview.frame = cgrectMake(0,320,self.view.frame.size.width,self.view.frame.size.height-64);
64= nabvar height(44)+ top bar (22);
hope this help :)

Resources