Objects not show when change iPhone size storyboard to universal in Xcode 7 iOS Objective C - objective-c

I have iPhone app and storyboard is done.
and every view in story board has iPhone size.
Now i tried to set any any size for views but it has problem.
when change size to iPad (any any) , all of objects in views will disappear and then running app , not showing anything in iPad view.
I don't wanna using another storyboard.
Target Device is Universal and i am using Objective C.
Thank you
Help me.

Update:
Resolve the issue with cells not appearing on iPad, needed to add the UICollectionViewDelegateFlowLayout methods for iPad.
Original:
If you get the size classes to regular width and height (iPad size classes), then set the constraints for your objects, I assume they are a width and height of 0, that's why you can't see them.
I think it's better to build constraints for (any, any) and then create specifically for iPhone or iPad if necessary, if you are creating a universal app.
Let if know if you encounter problems, hope this helps, good luck.

Related

How do I get my iPhone-only app to run on iPads? (constraint question?)

My iPhone-only Objective-C app (iPad not checked) runs correctly on SE 2nd up to iPhone 12 Pro Max, properly centered, fully functional, but is stretched and clipped on any iPad (in Simulator--I blanked center content below re privacy), and on some I get black screens. Every element is constrained ultimately centered on Superview X and Y centers (nothing absolute); is that the problem? Is there a typical problem that keeps iPhone-only apps from appearing properly on iPads? The app in no way does anything special for iPads. Is there a good tutorial about this subject? Thanks
The answer is simply that constraints sufficient for all iPhones are not necessarily sufficient for iPhone in iPad. Just because the app is sized correctly for all iPhones doesn't mean it's correct for iPhone in iPad. That's what this newbie learned!

iOS Universal Image Assets

For a new project my client wants to cover all iPhone and iPad sizes. For icons and sprites I'm not really gonna change the shapes of the images, but I'm in a bind with assets for my background images.
Looking at http://iosres.com I was wondering if there is some logic to cover both Landscape and Portrait 3:4 and 9:16 in one asset or should I simply make a set of iPhone and iPad and use UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad to figure out what to show before loading my views?
Also I'm wondering what's most effective for all the different device sizes. I know from experience that an iPad 3 wouldn't like to have a background image loaded on 4k resolution and that you want to avoid pixel differences so it won't trigger scaling in UIImageViews. Will iOS automatically figure out that the iPad 3 will use like the #1x variations, whereas the iPad Pro will load the #3x versions?
Yes iOS will automatically figure out which image to load at runtime and load #1x #2x or #3x depending upon the type of device. You don't need to do anything like UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad for each image.
Edit:
You can also add ~ipad suffix in image names so iOS will pick the appropriate background image for iPhones and iPads. i.e. image_name#2x~ipad.png and image_name#2x.png.

Size Class Design for Iphone and Ipad

I have to support both Landscape and Potrait for Iphone and Landscape for Ipad respectively, Under Size classes is it a necessary that i have to start with AnyAny first for basic layout and then proceed with compactwidth & RegularHeight for support Potrait orientation for Iphone
It doesn't really matter as for each size class you can set installed (as if, active constraint that will be fulfilled) constraints and which will be uninstalled ( disabled ). Just make sure that you don't have overlapping constraints and you are good to go. For more reference there is a great article: http://www.raywenderlich.com/50319/beginning-auto-layout-tutorial-in-ios-7-part-2
Also they have a book about iOS 8 and there you can find even more information.

How can Xcode 6 adaptive UIs be backwards-compatible with iOS 7 and iOS 6?

I just watched the WWDC video #216, "Building Adaptive UI with UIKit."
At about 45:10 Tony Ricciardi talks about changes to IB in Xcode 6 to support the new changes.
He says "You can deploy these documents backwards to older versions of iOS".
(where "These documents" presumably means XIBs and storyboards that have specific settings for different size classes.)
I'm not making this up. Go watch the WWDC video.
How is that possible? Trait collections and size classes are only defined in iOS 8. How can runtime behavior that's dependent on UI constructs that are new to iOS 8 work in previous iOS versions?
If it is possible it would be wonderful. You could build apps that will run on iOS 6, 7, and 8, and take advantage of the new flexible UI layout abilities that Apple has added to Xcode 6. I've created adaptive UI logic myself in code, and it's quite a bit of work.
Changes made to the UI with Size Classes in Interface Builder DO appear correctly on iOS 7 devices and the Preview in Xcode. For example, I changed some Auto Layout constraints and font sizes for Regular height Regular width and those changed constraints are visible in the iPad Simulator running iOS 7.0.
All size class optimizations are made available to iOS 7, except size classes that have a Compact Height. This has been confirmed by Apple and is now stated directly in the documentation:
For apps supporting versions of iOS earlier than iOS 8, most size classes are backward compatible.
Size classes are backward compatible when:
- The app is built using Xcode version 6 or later
- The deployment target of the app is earlier than iOS 8
- Size classes are specified in a storyboard or xib
- The value of the height component is not compact
Because iOS 7 doesn't respect a couple of size classes, if you use them you'll run into issues. For example:
When you have Compact w Any h defined and then Compact w Compact h defined, on iOS 7 it will respect the Compact w Any h but on iOS 8 it renders the Compact w Compact h appearance.
So, if you would like to utilize those two size classes and maintain compatibility with iOS 7, I would do any optimizations you desire for iPhone in landscape in Any w Any h or Compact w Any h, then perform your other optimizations for different size classes as necessary, and that way you won't need to use any size class with compact height and will avoid running into issues.
When deploying your app to iOS 7, Xcode will compile your storyboard in two different ways:
For iPhone, your storyboard gets compiled as "Compact-Regular" (Compact width, regular height), and this gets packaged as your "~iphone" nib.
For iPad, your storyboard gets compiled as "Regular-Regular" and gets packaged as your "~ipad" nib.
So if you're looking to deploy to both iOS 7 and iOS 8, you should focus your design on the Compact-Any and Regular-Any size classes. That will give you the best experience in terms of matching the UI across deployment targets. You are, of course, welcome to modify the layout for other size classes, but unless those modifications would get applied to the Compact-Regular or Regular-Regular size classes, then you would not see those modifications on iOS 7.
Note: This answer was relevant to a beta version of Xcode 6 and is no longer applicable to the shipping version. See answers by Joey and Dave DeLong on this page for proper information.
(original answer retained below):
While Storyboards/XIBs configured to use size classes will run on iOS 7, the OS does not currently respect those size classes and appears to use the default 'Any/Any' size class.
I agree that the particular slide you are referring to seems to promise such compatibility, but it doesn't appear to be the case currently (Xcode 6 beta 2).
To test, I created a project (iOS 8 SDK, deployment target of 7.1) with a single button that is centered vertically and horizontally in the Any/Any size class, but aligned to the top left corner in the Compact/Compact size class (e.g. iPhone in landscape). Xcode's Preview Assistant shows that the button changes its position in iOS 8, but not iOS 7. I confirmed this behavior on an iOS 7 device as well.
As some of the answers and comments were discussing the nature of backwards-compatibility, I thought I would share an excerpt direct from the Apple Documentation:
~~~~~
Deploying an App With Size Classes on Earlier iOS Versions
For apps supporting versions of iOS earlier than iOS 8, most size classes are backward compatible.
Size classes are backward compatible when:
The app is built using Xcode version 6 or later
The deployment target of the app is earlier than iOS 8
Size classes are specified in a storyboard or xib
The value of the height component is not compact
~~~~~
That last bullet point is targeted at this discussion, where Apple confirms that as long as "compact height" is not used, it should maintain backwards-compatibility.
Hope this helps someone!
While dealing with the similar issue I found another answer that I haven't seen here yet. Looks like Size Classes in XIB files are not working at all. If I create cell prototype in the storyboard file it works in iOS7 as explained in other answers, however when the same prototype cell is moved into separate XIB file - size classes are ignored in iOS7.
Here is link to the sample project demonstrating this behavior: https://dl.dropboxusercontent.com/u/6402890/testSizeClasses.zip
In the prototype cell I have four constraints from each edge of the grey view. Each of the is configured in a same way: Any/Any - 10, Regular/Regular - 20
It works fine in iOS8 simulator for both XIB and Storyboard, and in iOS7 only cells defined in Storyboard gets updated constraints on iPad:
If it saves anyone time, I believe that the way Xcode 6 provides quasi-backwards compatibility for size classes is via the historical ~ipad and ~iphone suffixed storyboards, and nothing more. This makes sense since size classes are a more abstracted way of how we previously defined an iPad storyboard, and an iPhone storyboard.
Therefore:
If your goal is to use size classes to support device family specific layouts (iPad vs. iPhone), then you are in luck: size classes are a nicer interface to the previously supported method.
If your goal is to use size classes to support altered layouts for different models within the same device family - ie. iPhone 5/6/6+ inc. landscape, then you are out of luck. Using these would require a minimum iOS 8 deployment target.
#lducool - In interface builder, in the Identity inspector, change 'Builds For' to iOS7.1 and later.
Unfortunately the answers from Dave and Joey do not work for me.
I am not allowed to comment in this thread, so please forgive me if this is the wrong place.
I have made up a specific question for that:
Example for iPhone portrait landscape adaptive UI which is backwards-compatible with iOS 7
From what I learned so far, I believe now that, like in my example, is is not possible to have 2 separate, different constraints for one ui element in portrait and landscape mode with iPhone iOS7 based on size classes.
Would be glad if I am mistaken, though.

xcode view size smaller than iphone

That never happened before iOS 6.
Now, I create an "auto layout", and I realized that the size was different in xcode, because the image was large but was correct in photoshop. When creating the app in the simulator, I have this:
I kept finding weird. So checked the size of the iPhone 5 and moved, as I always did, then looked like this:
When creating the app in the simulator, looked like this:
I wonder what happened with Xcode? Someone went through this already?
Thank you
It looks like you are working with an XIB that was identified as for iPad. In the Attribute Inspector, what options are you given under size? An iPad XIB has these options in Attribute Inspector - Size:
If that is what you see, you may have to create a new XIB, and be sure to choose Device Family - iPhone.