Looking to pin content above a segmented controller below parallax header - ios

I realize this is a general question, but any direction would be helpful.
So I am using this module https://github.com/maxep/MXSegmentedPager to try and recreate Twitter's profile page. One thing I am unsure how to do is get content above the HMSegmentedControl but is still pinned to it so it scrolls out of the way. When i add subviews to the parallax header view (in the xib file) they are totally static and dont move with the HMSegmentedControl menu.
Any ideas how I would tweak it? I dove into the MXSegmentedPager.m file but to no avail.
I suppose what I'm looking for is can i expand and put content inside a UIPageControl or in this case HMSegmentedControl?

So I was pointed in the right direction by the author of the module I was using, MXSegmentedPager. His MXParallax header already has space for content above the HMSegmentedControl and can be used for more than just one image.
Turns out any subviews you want to pin need their constraints to be referenced to the background imageView, not the superview. Only the background imageView itself its set to the superview of the nib.
Also, when putting several things in a uiview thats sitting on top of the background imageView, make sure it is referencing the background imageView but not on all 4 sides, otherwise it appears static. Typically you will want to set it to bottom left and right, and set a fixed height equal to height of the header you want to view when its at its resting visible point.
So, in hindsight fairly simple, but I overlooked it.

Related

Autolayout with stackViews inside a UIPageViewContoller Inside a Container View?

I’ve been struggling with this for a few days now…I can’t figure out how to correctly layout these constraints…. the bottom container view on the left is a UIPageViewController that loads the VC on the right…. that VC has a background view and 2 stackViews inside it… any ideas on how best to layout? I've tried constraining the leading and top of the background view to the safe area, then the same of the stackview (containing other stackviews) to the background view, but no matter what the stackviews display over each other?
The problem wasn't with auto-layout or my constraints, I was simply trying to fit too big of a view (the graph) inside it's superviews...when I shrunk the size of the graph, the existing constraints laid out the views perfectly.
To anyone else facing a similar issue however, Honey's comment is good advice, generally you should add the furthest "back" view first, add it's constraints, test to make sure it's correct, then repeat on each subview you add, as opposed to dragging all your views, then constraining them. The former is always the better approach. 👍

PageControl placing the marker in the position I want ios 9

I am creating a screen of an application that contains inside a custom cell one pageControll. It is already working properly but by default his marker comes down the contentView. How can I make the marker in the position I say? In case a little but within the above contentView
this is my screen:
I can think of two possible solutions.
Instead of adding the pageControl to the the cell's content view, add it instead as a child of the red view you have there.
In interface build add a constraint between the bottom of the content view and the pageControl.
Either should achieve the result you're looking for, if I understand you correctly.

Extra space on top and bottom of Init View Controller

I have a swift app I have been working on for some time now. I noticed that my init view controller has extra space at the top and the bottom of the view, so much that it allows me to pull up and down on the first view and let go and have it spring back into where it was. I removed all my constraints thinking I had an issue with them, but it's still done the same thing. The size class is set to any any, and all my graphic fit inside the view, yet I still an able to pull up and down.
I also made sure my view, wasn't a scroll view, it's not.
I looked around for similar issues, but couldn't find anything like this.
Thanks for the help!
Here is what my view looks like in IB
When I run the app.
Showing the amount I am able to pull it down from the top.
If you remove all of your constraints, and the storyboard is set to use auto layout, it usually won't show up correctly, as you have seen. You will have to add the constraints to each element in your view controller. To do that, you can control click on each and drag it where you want to connect a constraint. Or, use the pin and align buttons in the bottom right corner of the storyboard view.
There is a good tutorial from apple that I suggest you read. It will help you with the basics of using auto layout. Another option would be to not use auto layout. To turn it off in the Storyboard, go to the file inspector and uncheck the box "Use Auto Layout".

How to Reduce UICollectionView Size

I have this UICollectionView, layout scroll direction = horizontal.
I don't want it to occupy all page (as it does when you create it in IB), I need to have a header (another view) above it. This won't work using Accessories -> Header Section, when the scrolling is horizontal this header section sits to the left of the collection view. And it's not fixed, as I need my view to be.
Thanks
I was doing something similar and ended up just putting a UIView at the top that allowed me to put whatever I needed up there. It just solved a lot of problems for me.
I thought it was strange the way the header operates in the horizontal scrolling mode. It isn't really a header at all.
Revision -- I don't use IB at all, so it is all hand-coded -- but either way, you can do it. I've attached a screenshot of something I'm working on now -- it has a picker view and a youtube video at the top, where your header would be and a collection view down below. You could, of course, make your header view whatever size you want it to be and with whatever content. In this case I also have a footer that is a different view as well, but the concept is the same.

How can I make/program a UIlabel to scroll horizontally upon user input?

I'm making a simple calculator in iOS, and I want the user to be able to scroll the label horizontally when the end gets truncated.
How would I go about doing this? My original idea was to make two buttons that would move the label left or right by using stringpadtoLength type of method, but that seemed inefficient.
I see two ways of building this.
Use a UITextView and always return NO from -textFieldShouldBeginEditing:. This should get you 90% the way there very fast.
Build a custom control using a UIScrollView which contains a UILabel that uses -sizeToFit. This will be a bit more work, but will do exactly what you expect.
I went for Jefferey's second suggestion because I thought it would give a "cleaner" result. Turns out, it's not that easy to implement. Here's what you have to be careful about when you're putting a single-line UILabel inside of UIScrollView, in order to be able to scroll horizontally through the text.
The parent UIViewController should have the box "Adjust scroll view
insets" unchecked. If you forget this your text may be placed below the content of the UIScrollView, meaning that you can only see it if you hold it while over-scrolling down.
Call [self.toolboxItemNameLabel sizeToFit]; in your UIViewController's viewDidLoad in order to set the right size for your UILabel. This ensures that the scrolling is comfortable, going from the left to the right of the text.
When using autolayout, you must add constraints for the leading and trailing space to container of the UILabel which is inside of the UIScrollView. Thanks to this great post for the answer.

Resources