Wrong constraints under iOS 6 - ios

I am trying to reproduce the parallax effect we can see everywhere nowadays, where, whenever you pull down a scrollview, an image reveals behind it (see this question).
There's a bunch of solutions on the internet, but I'm trying to make it work using auto layout only. I saw someone got it working at a lightning talks a few days ago, but I guess I wasn't paying enough attention...
I got it working under iOS 7, however, under iOS 6, the image view doesn't stick to the top. Here's a sample projet with where I am right now : DCParallaxHeader.
Another question is, is there any way to make the bottom view size's dynamic depending on the screen's size ? (As it it wrapped in a scrollview, and we must provided the contentSize using the constraints too ?).

The person who make the talk wrote a blog post about it. Sums it all :-).

Related

Building for multiple screen sizes

One screen of my application involves displaying a form - asking the user to enter details which can be posted and saved eventually. In my form, I'm asking for the title, date, description, and attach any images. So there are UILabels, UITextFields, UIButtons, and UITextView involved. And they are displayed using interface builder + constraints.
Now as I view this screen on phones ranging from 8 to XR, I notice, for example in the XR, there is a lot of white space not being utilized. I understand the problem is due to my constraints. How do I adapt my constraints to help with this issue? So in the case of a longer screen such as an XR, my UIViews make use of the space provided rather than being bunched on the top half of the screen. I'm still a beginner w/iOS so I'm assuming it has to do something with constraints but not sure. How can I tackle this issue/change my approach when envisioning iOS applications?
Need some expert to enlighten me w/some iOS wisdom!
It's important to understand how autolayout and constraint works. After that you'll just need to create the UI ONCE in most cases and it will be good for all devices.
Since you're new I suggest putting one object(eg: UILabel) at a time and add constraints on it and see if it works before you add another object
Kindly see this link:
https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/AutolayoutPG/index.html
and there are a lot of tutorial videos in youtube you can watch.
happy coding

How to get iOS app to work on all iPhones? (Constraints)

I am fairly new to developing for iOS. I have a fully functioning program written in Swift and the UI was created in the scene builder on Xcode. I created an app for my work to simplify closing out the registers and other financial aspects. The app is complete and works perfectly, but was designed on the iPhoneX. The problem is that only a few of the employees have an iPhoneX, but they all have some kind of iPhone. I have tried setting up constraints but it never works. Ive tried scaling restraints and position restraints but I can't get the layout to look right on any other phone, and when I add the constraints it affects the view on the iPhoneX as well and doesn't look good on any iPhone. I need help getting this to work on all iPhones. I would like it to look and act the exact same regardless of the size of the phone, basically just scaled down. There are a lot of things on the screen and I can't figure out how to do this. Please help!!!
I have been working on this for a long time and I really need help. Please let me know if I need to clarify anything. I have posted links to some pictures of my UI so you have an idea of whats going on.
Constraints I tried adding, although I have played around with some other options.
Here's what it looks like on the iPhoneX, this is how I want it to look.
What it looks like on iPhoneSE (with constraints).
One thing I noticed in your Xcode project that none of your features are in UIView. Without it, it will be quite challenging and somewhat always different results. In theory, if you use AutoLayout features correctly it should work without UIView, but they make life so much easier. This is something I learned the hard way at the beginning of my iOS development. First set up your UIViews without any content inside it, give them some background colour to differentiate, once they are working on all devices. You can pin your features to superviews with no difficulty.
Since you have a repetitive features, you could also consider using Stack Views. You don't have complicated features, so as long as AutoLayout is set up correctly you should have no problems seeing it ok on all devices

autolayout- different devices and rotation

I am absolutely new in iOS programming. I wonder if a View contains 4 narrow rectangle subviews where they are constraints to four sides, like a picture frame, if I can make this program works in portrait, landscape; in all devices, iPad, iPhone( different version). The reason I am asking is to find out if not possible to consider concentrating and finding out about the possible options.
thanks
Yes, auto layout will do it. you might want to take a look at this tutorial to get started:
https://www.raywenderlich.com/115440/auto-layout-tutorial-in-ios-9-part-1-getting-started-2

All iOS screen size compatibility?

New to iOS developing here. Basically I am creating a soundboard app. I have the app essentially working (aka buttons returning sounds).
However my app only looks proper on the iPhone 6. I just have one ViewController in my main storyboard. When I run the simulator for the 4S/5/6+ or iPads, my buttons are pretty much everywhere.
I tried playing with size classes/autolayout through Apple's documentation, but couldn't get it working properly. What's the best (easiest ;) ) route I can follow to have it basically looking the same on ALL devices?
PS: I have one background placed too, I don't mind if it looks different on all devices since it's pretty minimalistic, but if someone can shed some light here too, that would be great.
Thanks!
You have a few options:
1) Continue your plan spending time getting friendly with Auto Layout and Size Classes. This might be difficult at first, but it will really pay off later. You should use the Assistant Editor's Preview mode to let you see iPhone 4, 5 and 6 side-by-side as you work so you can make sure your layouts look great everywhere.
2) Use a component like UIStackView where layouts are automatically adjusted to fit various devices. If your soundboard is as simple as a grid of buttons, you can do that in just a few minutes using a stack view.
3) Use a component like UITableView or UICollectionView where content is designed to scroll. Using this method you design only one sound button of your app (i.e., enough to play one sound) then have iOS replicate that across all the sounds you want. When your interface is presented on a device of a different size iOS will just make the content scroll.
Very roughly, option 1 makes you do all the work; option 2 makes your layout shrink down until it fits the available space; and option 3 makes your layout stay the same size no matter what, but you should expect it to scroll on some devices.
There is no right solution; it's entirely down how you want your app to work.

Basics on how to setup horizontal paging in iOS app?

I've looked for this for a while, but I can't find any good guides or resources that explain it thoroughly (not even Apple's own documentation, which seems to not have as much information as I'd expect). I want to setup a basic interface that has 6 pages horizontally. Each page will have a bunch of labels and textboxes, but the layout will be the same for each page. Eventually, I want to be able to have each page scroll down to view all the content, but I'm assuming I just need to use scrollviews as the content for each page.
Also, each page will eventually have to have separate names for each textbox (and separate from the other pages too) because I'll need all the content of the whole app to be saved out later.
But really, for now, I just need to figure out how to get paging working. I tried following one demo but when I typed in the code, Xcode wasn't recognizing one of my classes (which I know I included it). Plus, I didn't understand what was going on really, and I feel that I need to understand what I'm coding.
Also as a side note, how do I start programming for iOS 5? I updated Xcode to the latest version which said it had support for iOS 5, but I only get up to 4.3 in my project target.
You can use this project http://cocoacontrols.com/platforms/ios/controls/icarousel, the only downside is it does not support cell reuse, so if you plan on having more than a 5 or so panels the app will really start to blog down.
For any future searchers that have found this thread, I was able to achieve what I wanted.
Basically, just make a scrollview the size of however many pages you want (multiply the width by how many pages you want and that will be the content width). Then just enable paging in interface builder and it will page through the view. Then you can just add content to the scrollview.
It's not hard. When I did it for some of my apps, I had a very detailed 'template view' which included primarily a tableview, but also lots of buttons and text fields and such. I was amazed at how well it all worked when put together -- no real trouble with gestures or anything. Apple's UIPageControl sample code is a good place to start.

Resources