tranisition from iphone to ipad nibs - iphone

i am wondering how its possible to have an iphone nib that has some uitextfields and some labels to be automatically repotitioned if the device is an ipad. (i dont want a second nib) im trying to get my iphone nib to autoresize in the middle of the screen if the device is an ipad so that all the text fields and buttons arent placed in the top left corner. I tired using the autosizing masks however they wouldnt work for the textfield(im not sure why exactly the horizontal autoresize didnt work) is there any way i can do this without making a new nib if the device is an ipad?
thanks

I'm unsure if this would work, but you might try using a view that's the same size as the iPhone screen, set the autosize flags on that to keep it in the middle of the screen without stretching it, then put all of your views inside that view.

Related

Layout for iphone 4, 4s and 5 on same storyboard

I'm making an app for iphone. My layout can be the same for iphone 4, 4s, and 5 but for the iphone 4 and 4s the only thing that change is space between buttons. I finished my app and i arrange all storyboard to run well on iphone 5. Now i only have to tell that when the app running on iphone 4 and 4s i have to change the space between the buttons in some views to get all buttons inside screen. How i can do this? I can use auto layout i think but i dont use this. Its possible to help me? I do the things right, doing the design first for iphone 5 and now adapt for iphone 4 or im doing the things in the wrong way.
Regards
The IOS6 autolayout it's still a bit "wild" and it will also disable the IOS5 compatibility.
If you don't use autolayout, you can still set some rules in storyboard at size inspector, like tide you buttons to the top or the bottom of the view, so you can control where they go when the screen shrinks.
A better way is to add subviews to your view, and allow the subviews to shrink and expand (also # size inspector in storyboard). Then add your buttons to those subviews, tide them to the top, bottom, or let them untied/free if they are placed symmetrically inside the subview.
You can simulate quickly with the form factor button in storyboard (right-down corner) to see where the buttons go when you switch the sizes.
These methods require zero lines of code, but more work with the storyboard.

Can't have a UIViewPicker well laid for iphone 4 & 5

I have one storyboard file for iPhone devices, and in one of the views there is a subview that contains a UIPickerView, and, when it runs on the iPhone 4 the UIPickerView is stuck at the bottom of the view as it should be, but when it comes to the iPhone 5, the UIPickerView appears a little above of the bottom of the screen.
If I fix the problem for the iPhone 5, the UIVPickerView won't appear completely when I run it on the iPhone 4. (half of it appears below the screen)
So is there a way to have the UIViewPicker well laid for both iphone 4 and 5 resolutions?
NOTE: I solved the issue by creating a completely new subview with the UIPickerView. Now it is well laid whatever the device is.
When creating the picker, you need to use the size of the screen to determine the location. It seems like you are just putting in the coordinates for the y manually, which only works when using one screen size.
If your view that you are in is the same size as the screen, as it most likely is but may not be, you can do:
int y = self.view.frame.size.height;
and use that as the y-coordinate of your pickerView.
Otherwise, you can find the size of the screen by using:
[[UIScreen mainScreen] applicationFrame].size.width //if in portrait
//or
[[UIScreen mainScreen] applicationFrame].size.height //if in landscape
Then you have to subtract the height of the navigationController from that if you have one.
If you're using autolayout, you should be able to change the constraints the picker uses to get it to stick to the bottom. Select the picker, click the "H"-shaped autolayout menu icon in the bottom right corner of the storyboard, and choose "Bottom Space to Superview". Then delete any constraints attaching the picker to the top of the screen. If that doesn't work, make sure that all of the picker's superviews have constraints to attach them to the bottom, too; you'll have to decide whether you want them to resize or slide down on an iPhone 5.
I fixed the issue. Not sure what was going wrong but I deleted the subview, then created a new one and added the UIPickerView. Surprisingly, now it is well laid whatever the device is.

AutoLayout problems in iPhone5

I have a Xcode 4.5.2 Project
I have a story board with with four UIViews.
Autolayout is Set to ON in the StoryBoard
Deployment is iOS 6
I want the letterbox to appear on top and bottom when running on iPhone 5 and not have my views resized when running on a iPhone5
When I run my app in iPhone5 - I do not see the letterBox - the UIViews are automatically stretched (incorrectly)
When I run the App on iPhone 4 - Everything is as expected.
Why does the letterbox not show as I would expect?
If for some reason you want your app to behave on iPhone 5 the way older apps do -- automatically letterboxed by the OS to 3.5-inch screen dimensions, just don't include a Default-568h#2x.png in your app. However, Apple expects new apps submitted to the App Store to support 4-inch screens, so you might not get very far with this strategy if you're expecting to distribute your app that way.
If you want to "support" iPhone 5 (and iPod touch 5th generation) screens, but keep most of your UI at older screen sizes... well, your users may not like it (and the App Store reviewers might not either), but it's possible using Auto Layout. The catch is that the root view in your window's (or rather, your view controller's) view hierarchy is always automatically resized to fit the screen -- but there's no saying that has to be the main container for your actual UI content.
In IB, with the editor in 3.5 inch screen mode, drop a new UIView into your view controller's root view. It should automatically size to fill the screen (460 points high).
Add a Pin > Height constraint so the view stays 460 points high no matter how its superview gets resized.
Add an Align > Vertical Center in Container constraint so the view stays centered when the height of its superview changes.
Put all of your UI inside this view.
Now you'll get white bars (change the color of the root view if you like) above and below your UI when on iPhone 5.
Note this only works as long as your UI doesn't rotate to landscape. I don't think you can do this kind of artificial letterboxing for both orientations using only one set of constraints, so if you want to support rotation you'll need to respond to an orientation change by switching out constraints programmatically -- pin height and center vertically in portrait, pin width and center horizontally in landscape.

Camera Overlay height for both iphone 4 and iphone 5

I'm using the standard UIImagePickerController and using a camera overlay view with it, default controls. I've got an external nib file which I load the overlay view from. The problem is that the view seems to be at 460, so doesn't fully encompass the camera view on iphone 5. I'd like to approach this using auto layout, but I'm not sure how to tell the nib to adjust it's size to be either a height for iphone 4 or iphone 5.
I thought about using setFrame, but that's very un-auto layout. I've also thought about having 2 different nib files, one for iphone 4 and one for iphone 5, but that seems to be the wrong approach too. I'm guessing there's some way to tell the nib to fill the current camera view, but I'm not sure what it is. Can someone recommend the "correct" way to handle this?
You can programmatically load a different cameraOverlayView XIB based on the phone dimensions. The camera controls strip is about 54px tall on 480h screens, and about 96px tall on 568h screens.
Alternatively, you can certainly design your XIB with auto resizing masks set appropriately, but will need to then do a setFrame in code to get the right dimensions.
So either way, you're writing some code to detect the screen bounds and either loading a different XIB or doing a setFrame.
I haven't used nibs for a while now (preferred storyboard) but I believe what you have so far is a UIImageView in the nib, right? Make that an outlet. And then in your m file, check for dimension of the device (many people have asked this recently how to check screen dimension), then you set the uiimageview frame based on the found dimensions. It should work ;)

how to create app which can view larger than iphone screen

i create a new InputData.xib which has few text box which actually larger than iphone screen, but when i exe the app, text box which in beyond the iphone screen is hidden and i unable to scroll the screen, how this can resolve,
thanks
In general, the iPhone screen has a window that is of fixed size and position. All scrolling needs to be done with UIScrollView objects. UITextView is a subclass that works well for text. UITableView is for lists, like in the iPod app. UIScrollView itself can be used for anything else.
You should probably use a UITextView, rather than a UITextField. Make its bounds equal to the screen bounds; if there's more content than will fit, it will handle scrolling within it automatically.