I've got an universal iOS app which can run on iPhone or iPad.
On iPad I can't see the content of the UICollectionViewCell, but I'm able to see them if I add a background color to them.
Here is the code : https://github.com/rvi/collectionViewTest
Screenshot on iPad :
Screenshot on iPhone :
What am I missing ?
You have to set the delegate of the collection view to get the collectionView delegate methods called. And also add the collectionView to the view of the view controller. I can't see those things on the ViewController.swift file.
You can set up the cell in wAny|hAny size class, and you will see it on iPad. Right now the cell in size class for iPad is grayed out. Another way is to add switch and button for size class wRegular | hAny.
The solution was close to the one proposed by gabbler, is to select wAny|hAny size class on the subviews (button and switch), like this :
Related
I have a requirement to show the Data in Linear Vertical List in iPhone and
in Collection/Grid in IPAD
In the iPhone, it should look like
But In Ipad, it should look like
I have already implemented in iPhone through table view but don't know how to show it as grid view in IPAD
Here are my questions
should I have to create the Separate view controller for Ipad if yes
then how can I define two view controller one for iPhone and other
for iPad
what is the best way to achieve this?
please help me I am trying to implement it but can not find any way.
(Note)Images are copied from Vimeo iTunes app https://itunes.apple.com/us/app/vimeo/id425194759?mt=8
You don't need to create two different controller's for IPAD and IPHONE. Just create one controller with UICollectionView and then use UICollectionViewFlowLayout for your UICollectionView to set layout of UICollectionView according to the device weather it is IPAD or IPHONE Try this solution if you have any doubt pls let us know.
Try this solution
UICollectionViewFlowLayout *collectionViewFlowLayout = [[UICollectionViewFlowLayout alloc] init];
[collectionViewFlowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
self.myCollectionView.collectionViewLayout = collectionViewFlowLayout;
Also you can use multiple properties of UICollectionViewFlowLayout.
Check this solution and let me know if it works for you.
Check these links for reference :
https://www.raywenderlich.com/136159/uicollectionview-tutorial-getting-started
https://www.raywenderlich.com/107439/uicollectionview-custom-layout-tutorial-pinterest
The way to do this is with Adaptive Layout and size classes in the storyboard. You don’t need to write any code at all, and you are also covered for multitasking/split-screen and future iOS devices of unknown dimensions. You can make any view appear or disappear according to weather the width is compact (like the iPhone) or regular (like the iPad). In the views inspector you can add a variation for compact width like this:
Adding a compact width variation to view
Click add variation and untick “installed”. Now that view will only be installed when the device has compact width. You can do this with a container view with an embed segue to a UITableViewController.
If you view the storyboard as an iPad ( by clicking the little icons at the bottom where it says “view as”) that view will disappear. Replace with another container view that segues to UICollectionViewController and do the same again, but this time add a variation with regular width.
Thats it.
(Sorry, I don't have enough points to show images)
Here is a Demo project that creates something like the layout and behaviour you want. All the action is in the storyboard, the view controllers are just skeletons.
I am designing a table view in which I have a custom cell in which I am trying to design a few views and sub views. I have placed my views as per the following hierarchy and constraints -
And here is my main story board -
I have given my table view cell's content view as orange colour and I have placed a view with yellow colour. I have pinged it to the content view of the cell. My storyboard is of the size 600*600 freeform(Size class - wAny hAny). When I run my app in ipad, it keeps a space as shown below between the cell's content view and its subview even on pinning the subview to all sides of content view-
So,what might be my problem and what mistake am I making? Thanks.
I think the problem is because of the sizing classes (like in the image).
if your app is universal (for both iPhone and iPad) make sure you choose it like the screenshot (w Any, h Any).
Please let me know the current settings.
Update
After sending me the storyboard. I have used it as it is in a new project. and that's how it looks in both iPhone and iPad
It looks fine in both of them. my best guess is it's a problem of the
preview only(which doesn't matter).
If you change the scene size from iPhone 4 inch to inferred
it solve the problem in the preview as well.
I am making a custom keyboard for iOS. I am using a .xib file for the design, and I am using an IBAction to pull the title of each button on click in order to type. The keyboard is working correctly, and appears perfectly fine on an iPhone 5S and below (.xib dimensions are 320 width x 160 height). However, when viewing on any bigger screen, the keyboard does not appear correctly.
Am I supposed to set certain constraints? How do I use size classes in this scenario? Would it be better to programmatically add constraints or add them by hand?
Link to beta keyboard (not even close to complete) : https://drive.google.com/folderview?id=0B7XwRCOfrcP2eFZ1dlJtX0V2THM&usp=sharing
first you should select view of your custom keyboard
then select add constrain option
than select constrain like below images
give static height which you want,
default keyboard size is 216
Yes simply just Copy your keyboard.xib view and pest it on your view controller but you should set all button constrain , i put it on main storyboard see in below image & then you can add size class otherwise you should go programmatically
When I add a UIViewController to a storyboard in the latest xCode its view is defaults to 600x600 in size. This means centred items appear off to the right and the view extends off the bottom of the screen. Why is this?
Many thanks,
Ben
in Xcode 6 the interface builder works with AutoLayout. So you need to set constraints to your views to be in the right place. See here how thats works: Click me
But you also can disable the size class to work in the exact ViewController like this:
If you turn size classes off you see an window like this:
Just select the size class you want (iPhone for example) and you can work like you want it.
But I would recommend to work with AutoLayout due to the fact that there are a lot of different device types (iPhone 4(S), iPhone 5(S), iPad).
How do you change the width of the UITableViewController in an iPad SDK 3.2. It seems that it is fixed just like the iPhone UITableView.
I got your requirement what do you want to do in you application. Here you can carry out it in different way.
Instead of using UITableViewController, please use UIViewController and then add UITableView inside the UIViewController. Here you can change the frame size of UIView as you want. But you can't change the frame size of UIViewController as it is the base view and it will be the same as iPad screen. Please do like this and let me know if you have any questions or doubts.