UISearchBar embedded in UIBarButtonItems (IT IS iPad document!) - ios

I had UISearchBar embedded in UIBarButtonItems for a years in the iPad storyboard. Now when I turn Use Size Classes on, the storyboard (which is using exclusively for iPad), throw the compilation time error:
UISearchBar embedded in UIBarButtonItems (Only available in iPad
documents)
Is there any way to let XCode know that the storyboard is using with iPad only!?

This was a bug with Xcode. Apple fixed the bug in Xcode 8.2. Now you can use UISearchBar in UIToolbar in adaptive storyboards.

Related

How can i create common xib for all ipads and iphones without creating seprate xibs for iphone and ipad? Not storyboard

Current xib's showing layout issues while switching between devices. I need single xibs which support all ios devices instead of using storyboard.
If you are using xcode 7.3 and above you can vary the constraints based on size class
https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/AutolayoutPG/Size-ClassSpecificLayout.html
for xcode 8 there are some updation but underlying concept is size class , please check this
http://www.appcoda.com/auto-layout-guide/
https://makeapppie.com/2016/09/05/an-introduction-to-size-classes-for-xcode-8/

Views have indention after opening storyboard in xcode 8

I want to upgrade my iOS 8 App to iOS 10 (In House App). After opening the project in Xcode 8 and running the app on an iPad/Simulator all custom views have indention from the navigationbar. (UITableViewController do not have this Problem.)
View as seen in IB
This is the View in the Interface Builder.
These are the settings in the inspector
View in Simulator
As you can see, the border of the "P"-Symbol has an unintended indention. The TableView Section Header is also not visible in the simulator.
So my Question is: How can I fix this? I tried to set the Storyboard Document type to Xcode 7.

Size classes with xib files not working

Currently, I'm working on universal app (iPhone / iPad) supported on iOS 7 & iOS 8.
Here is my problem regarding size classes :
My navigation bar is defined into a XiB file (NavBarView.xib)
Inside this file, I have a UIButton that I want to display only on iPhone mode, and a UISearchBar only for iPad mode.
To handle that whitout any line code, I used the new feature "Use size classes" available for views since iOS 8. I defined "size classes" for these two elements inside my XiB file.
UISearch for Ipad : Installed for all layouts except Compact Width / Any Height (wC hAny)
UIButton fo Iphone : Not installed for all layouts but with Compact Width / Any Height (wC hAny)
This mechanism works pretty fine on iOS 8 for iphone and ipad, but not on iOS 7. However, if I apply these size classes direclty into views contained into the storyboard, it works for iOS 7.
Could anyone explain me why my size classes are not working when they are defined into XiB files on iOS 7 ?
Best Regards and many thanks,
Lorenzo.
Barely anything to do with size classes is supported under iOS 7. Some good answers here: How can Xcode 6 adaptive UIs be backwards-compatible with iOS 7 and iOS 6?
Adding as an answer since saadnib's comment on the original question helped me a lot.
Size classes on XIB files not being backwards compatible is a bug that has been fixed on xCode 6.1.1. Strangely it's not on the patch notes but I can confirm I'm using a single xib to provide 2 different layouts for a cell on iPad and iPhone. This only started working once I updated from 6.0.1 to 6.1.1.
Limitations on backwards compatibility for classes on storyboards still apply, but they can be worked around.
Figured another option. Size classes will not work, if you add xibs view as subview to UIApplication.shared.keyWindow.
View must be in UIViewController view hierarchy to support size classes.
Thanks to #IvanKvyatkovskiy

Using iPad and iPhone storyboards in Xcode

I have created an app with a storyboard in Xcode and I now want to create an iPad version. I successfully created an iPad storyboard, but it currently runs with the code from the iPhone version.
The issue I am having is that the code for the iPhone is still running with the iPad storyboard. I would like to duplicate the iPhone code and adjust it for the iPad.storyboard, but I am not sure how to do that. Thanks.
I took a screenshot for you:
So switch the tabs and assign the appropriate storyboard. and make sure it is set to universal.
If I understand your problem, you now have two storyboards, one for iPhone and one for iPad, which are both working properly, but you want to modify part of the code just for the iPad version.
You should duplicate the classes you want to edit for the iPad version of your app and assign those new classes to the corresponding ViewControllers of the iPad storyboard.
Of course, you are still making a single, universal app.

Xcode storyboard: Why does the iPad storyboard show iPhone sized views?

I have a universal app that uses storyboards. There is an iPhone storyboard and an iPad storyboard. However, in interface builder, the viewcontrollers for the iPad storyboard are still sized for the iPhone. How do I get the iPad storyboard to show iPad sized view controllers?
I realize that the view controller display in interface builder is design-time-only eye-candy, but having iPhone sized VCs makes it really hard to lay out the UI correctly.
After some digging through the storyboard source code, it turns out that the iPad storyboard was copied from the iPhone storyboard. So, the question really became how do I convert an iPhone storyboard into an iPad storyboard?
The answer is surprisingly simple. I ran across this SO answer -- to convert an iPhone storyboard to an iPad storyboard, do the following:
From Xcode, right-click on the storyboard and choose Open As ->
Source code
Search for targetRuntime="iOS.CocoaTouch"and change it to targetRuntime="iOS.CocoaTouch.iPad"
Right-click on the storyboard again and choose Open As -> iOS Storyboard
The storyboard will now show all views in the correct size.
When you first create a storyboard you select a Device Family (iPhone or iPad) that the storyboard is targeted for. I don't know of a way to change the device family once the storyboard has already been created.
However, to solve your problem I recommend the following:
Create a new storyboard by going to: New -> File -> User Interface -> Storyboard (Be sure to select Device Family = iPad when choosing the options.)
Go to your old storyboard, select and copy everything by pressing Command-A, Command-C. Then go to your and paste everything by pressing Command-V. Your view controllers will now be iPad-sized.
You can then delete the old storyboard and rename your new storyboard to whatever the old name was.
This answer is not a solution, but will help to get one of the reasons why such things happen.
The issue occurs when you try to disable:
"Use Auto Layout"
When you uncheck it, the popup window appears. There is select:
"Keep size class data for: iPhone", by default is selected iPhone (no matter which iPad or iPhone project you created).
If you will not mention on it, your storyboard will be auto converted to iPhone sizes.
Do not forget to choose right device.
I used the suggested answer to convert an iPhone storyboard to an iPad storyboard and it worked great for most of my views. However, I realized that one of the views was still iPhone storyboard sized. The reason was because I had locked All Properties of one background image (because I did not want to accidentally move it). Removing the lock turned the view back into iPad sized. This might help someone stuck on this.
Make sure you set the right Storyboard in Target > General. This kinda stuff makes me headache for 3 hours before i realise i set the same storyboard for iPhone as my iPad storyboard.
In my universal app, I was using SpriteKit for the main viewcontroller. The SKScene.scaleMode was set to aspectFill. When run in the iPad simulator, the app started up iPhone mode. Solution was to set scaleMode = .resizeFill.
For me i have found it more easy by changing the view controller presentation to Full Screen rather than Automatic, I use Xcode 12.1

Resources