Search code examples
iosiphonexcodeautolayoutsize-classes

Size class specifically for portrait 3.5 inch (iPhone 4S) Xcode 6?


I'm tuning my UI App, but I got an issue that I can't solve.

As I can see Compact height affects all iPhones under 4.7 inches, but my UI is fine except for the iPhone 4S (3.5 inches).

I don't want to modify the layout for all iPhones under 4.7 inches, just the iPhone 4S, at the same time I don't want to left out this device.

There's any workaround so I can set the amendments but just and only for the 3.5 inches portrait? or should I say goodbye to 100 millions devices out there?

I know it's a tough question and almost an opinion poll, but technically speaking I would like to find my best way out here.


Solution

  • @all I can't make things smaller, because I'm dealing with pickerviews which happen to have only three valid heights for UIPickerView (162.0, 180.0 and 216.0). Sizes and constraints apart.

    iPhone Sizes: http://www.idev101.com/code/User_Interface/sizes.html , 4S is unique.

    So although my approach it's a little bit ugly get the things done, nearly on my point.

    So I know it's far from Goodville, don't hit me down, just for sharing:

    func checkForiPhone4S()
    {
        if (UIScreen.mainScreen().bounds.size.height == 480) {
            println("It is an iPhone 4S - Set constraints")
    
            listPickerView.transform = CGAffineTransformMakeScale(1, 0.8);
    
            var constraintHeight = NSLayoutConstraint(item: listPickerView, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1, constant: 100)
    
            self.view.addConstraint(constraintHeight)
    
            datePickerView.transform = CGAffineTransformMakeScale(1, 0.8);
    
            var constraintHeightDate = NSLayoutConstraint(item: datePickerView, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1, constant: 100)
    
            self.view.addConstraint(constraintHeightDate)
    
        }
    }