iOS Layout frame issue - iphone

I have a view which perfectly fits all other screens except iPhone 4s and below.At first I implemented scrollview for the view in iPhone 4s and below, but now scroll view has to be removed and the only go is to check weather the device is below iPhone 5 and adjust the frame so that content fits in screen. I have checked and tried updating frame of the view for models below iPhone 5.This doesn't work and the frame doesn't get updated as I am using auto layout. In short if the model is below iPhone 5 i want to update my y of the origin of the frame so that view is completely seen. Any methods ?

It is a little bit difficult to understand your question.
If you set the bottom layout constraint of the scroll view to be in line with the bottom layout guide of the main view, the scroll view should resize to fit the screen regardless of the model of phone.
It sounds like your issue is not with the scroll view frame but with the size of its content. I am not entirely sure though what exactly the issue is... i.e. what you are seeing versus what you would like to see.

Related

How to get the visible view size in iOS13 when presenting a view controller

In iOS13, the default way when presenting a view controller was changed to the "sheets/cards" view. As I’m not using auto layout (why not, is not really important and relevant), I rely on getting position of elements based on the frame of the view.
Now, the problem with the new method is, that the view frame doesn’t really reflect the actual content size visible on the screen anymore. E.g. if I have positioned a UIButton at the bottom on the view controller based on the view.frame bottom coordinate, it will be now cut off, as the view is actually moved down in the amount of the nice "sheets/cards" visual indication at the top. The same problem is even more evident in an iPad, where centring another view in the view controllers view will be offset, due to the fact that the default presentation style is now a "sheet" in the middle of the screen.
I’ve currently changed everything to force the full screen version, but it would be nice to use the new fancy design.
Anybody has any idea how to get the actual visible rect/coordinates in the new style without changing things to auto layout?
Here are how they look. The "flower" is centered in the view and the X button should not be so close to the bottom or missing completely in the iPad version.
Finally figured it out. As I was setting the positions of items in viewDidLoad, the frame was not calculated correctly, thus resulting things being laid out incorrectly. When resetting the frame and positions in viewDidLoadSubviews, the positions were placed correctly.

Contents of UIViewController not adapting to iPhone 4s layout

I have a view controller with some fixed labels, steppers etc. The layout looks fine in iPhone5, 6/6 plus, but when i try in iPhone4s the view just doesnt scroll down to show other content.
Should the scrollbar not appear automatically when the content does not fit in screen size?
Here is how the layout in iPhone 4s looks along with how it should actually look
It would be great if someone can help me identify why is the content not scrolling for iPhone4s
Thanks in advance
No, it should not scroll automatically. You need to embed your view into a scroll view or (better) use table view.

Layout differencies in Interface Builder and real device screen

I' m developing an application for both Retina 3.5 and Retina 4 screens (iPhone family). And I encountered with the next problem. I create a view in .xib file and set size to Retina 3.5 full screen.At the very bottom of the screen I placed a view with UILabel. You can see the view on the screen:
As you can see the view is at the very bottom. But when I run the application either on device or the simulator view with label on some reason doesn't fit the screen:
So the question - what can be the problem? How can I fix this? Why IB view sizes is not correct?
You've set your NIB to not have a status bar, but your app does have one. This means your NIB is sized at 480 pts high (on a 3.5" screen), when it should in fact be 460 (due to the status bar). This pushes your view down by the corresponding height (20 pts, which you can see at your cut-off label at the bottom).
There are a number of fixes for this. You could just tell your NIB it has a status bar, but a better option would be to set your view to resize dynamically according to its bounds. Exactly how you do this will depend on whether you're using auto-layout or not, but you'll want to check 'autoresize subviews' and make sure your view elements stay locked where you want them to.

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.

Why do my UIImageviews get resized/dimmed when using UINavigation/UITabbar controller

I have an app with a primary view that has a UITabBarController with 5 tabs. Each tab is a UINavigationController.
In interface builder, I'm customizing the background of each page by dragging a UIImageView and setting it fullscreen. The image I'm setting to the view is 640x960. I am setting it to be Aspect Fill.
However, what I've noticed is that it is not where I would expect it to be. When navigating between by tabs, the image seems to be shifted down from where it should be.
Also, when pushing a new view to the navigation controller, the background of this new view isn't offset in the same way as the tabbar one, and it is also slightly dimmed.
How can I set my UIImageViews on each page to be aspect correct and fill the screen 1:1? Also, how does one disable the dimming when pushing a view to the navigation controller?
Thanks for any tips, and apologies if this is covered in another thread, I couldn't find an answer searching the site.
Assuming that you are using the IB to setup your views, you should select navbar/tabbar options to reflect what will be on the actual page. That should place your image correctly. I would also recommend that you make both a low res and hi res version of your background images -- 320x480 and 640x960. Of course, your size may need to be adjusted (reduced) for the navbar and/or tabbar which will leave less than 960 px of vertical height -- probably more like 920px if you are in portrait mode. Then you add #2x to the base name of the hi res version, this would account for older iPhone screens.
Once you have the image placed correctly, resizing should be unnecessary. You can have the image automatically resize width and height using the little arrows on the layout page -- that's a bit hard to describe. It can also be done in code -- if you still need that I can provide a sample.
Maybe you need to set all AutoresizingMask in order to resize the UIImageView properly on each view. And to main aspect ratio u should use either AspectFill or AspectFit on the contentMode.