Re: UIScrollView contentSize question
Yaay! On Sun, Jun 22, 2014 at 12:10 AM, Kyle Sluder k...@ksluder.com wrote: On Jun 21, 2014, at 9:13 PM, Luther Baker lutherba...@gmail.com wrote: I want a 2-page horizontally scrolling UIScrollView on a simple UIViewController. Very similar to what Twitter does to swipe between Home, Discover and Activity views. Using storyboards, dropping a UIScrollView on a UIViewController is a piece of cake. Pinning the UIScrollView to the top and bottom layout guides - left and right parent view edges, piece of cake. I can paint the background bright green and see it just fine. What is the best way to layout the 'content' views? I want them to be the size of the UIScrollView's frame. Specifically, what is the best way to do this using AutoLayout? I know that Autolayout will cause the UIScrollView's contentSize to adjust to fit its child views ... so does that mean I need to create height and width constraints on the child views - ie: I need actual numerical values? Nope. You should be able to create an equal-width constraint between the scroll view and one of your page subviews. Then make the rest of your page subviews equal in width to the first one. You’ll also want to do this for the height. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: UIScrollView contentSize question
I've got that working in code ... thoughts on how to do this with storyboards? Or at least, I'd like to create the children views themselves in the storyboard. When I 'freeform' the view controller to allow me to show a UIScrollView that is 2 pages wide, binding the first view to the width of the scrollview (which is 720.0) and then pulling that view's display frame back to half that (to place two children side by side) creates inconsistent constraints wrt to the child view / scrollview widths. ( I followed a bit of what Rob talked about here http://stackoverflow.com/questions/16889123/how-to-add-objects-to-a-uiscrollview-that-extend-beyond-uiview-from-storyboard/ and then watched a bit of his video here https://www.youtube.com/watch?v=PgeNPRBrB18feature=youtu.be ) On Sun, Jun 22, 2014 at 6:52 PM, Luther Baker lutherba...@gmail.com wrote: Yaay! On Sun, Jun 22, 2014 at 12:10 AM, Kyle Sluder k...@ksluder.com wrote: On Jun 21, 2014, at 9:13 PM, Luther Baker lutherba...@gmail.com wrote: I want a 2-page horizontally scrolling UIScrollView on a simple UIViewController. Very similar to what Twitter does to swipe between Home, Discover and Activity views. Using storyboards, dropping a UIScrollView on a UIViewController is a piece of cake. Pinning the UIScrollView to the top and bottom layout guides - left and right parent view edges, piece of cake. I can paint the background bright green and see it just fine. What is the best way to layout the 'content' views? I want them to be the size of the UIScrollView's frame. Specifically, what is the best way to do this using AutoLayout? I know that Autolayout will cause the UIScrollView's contentSize to adjust to fit its child views ... so does that mean I need to create height and width constraints on the child views - ie: I need actual numerical values? Nope. You should be able to create an equal-width constraint between the scroll view and one of your page subviews. Then make the rest of your page subviews equal in width to the first one. You’ll also want to do this for the height. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
UIScrollView contentSize question
I want a 2-page horizontally scrolling UIScrollView on a simple UIViewController. Very similar to what Twitter does to swipe between Home, Discover and Activity views. Using storyboards, dropping a UIScrollView on a UIViewController is a piece of cake. Pinning the UIScrollView to the top and bottom layout guides - left and right parent view edges, piece of cake. I can paint the background bright green and see it just fine. What is the best way to layout the 'content' views? I want them to be the size of the UIScrollView's frame. Specifically, what is the best way to do this using AutoLayout? I know that Autolayout will cause the UIScrollView's contentSize to adjust to fit its child views ... so does that mean I need to create height and width constraints on the child views - ie: I need actual numerical values? If so, I clearly don't want to hard-code 320.0 as the width ... so is it appropriate to CGRectGetWidth(scrollView.frame) or CGRectGetHeight(scrollView.frame) and rely on frame or bounds values of the parent to setup the autolayout stuff in the children? Clearly this can only be done after the scrollView has loaded and positioned itself. It feels weird to mix the two abstractions and have to wait until the scrollview is positioned before creating the constraints on the children - feels dangerous/brittle. Feels like I'll have to manually handle device rotations, etc ??? Thanks, -Luther ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: UIScrollView contentSize question
On Jun 21, 2014, at 9:13 PM, Luther Baker lutherba...@gmail.com wrote: I want a 2-page horizontally scrolling UIScrollView on a simple UIViewController. Very similar to what Twitter does to swipe between Home, Discover and Activity views. Using storyboards, dropping a UIScrollView on a UIViewController is a piece of cake. Pinning the UIScrollView to the top and bottom layout guides - left and right parent view edges, piece of cake. I can paint the background bright green and see it just fine. What is the best way to layout the 'content' views? I want them to be the size of the UIScrollView's frame. Specifically, what is the best way to do this using AutoLayout? I know that Autolayout will cause the UIScrollView's contentSize to adjust to fit its child views ... so does that mean I need to create height and width constraints on the child views - ie: I need actual numerical values? Nope. You should be able to create an equal-width constraint between the scroll view and one of your page subviews. Then make the rest of your page subviews equal in width to the first one. You’ll also want to do this for the height. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com