I really wonder why my scrollview is not scrolling when testing it in a 4 inch iPhone simulator and real iPhone 5. Everything works fine when I run it in 3.5 inch simulator/iPhone4s.
By the way, I'm using autolayout, and upon checking the scrollview.frame.size.width and scrollview.frame.size.height via NSLogs, the values are okay but the scrollview is not scrolling when I run it in a 4inch simulator/iDevice.
What could be the problem? Thanks for the answers.
I think you should check nslog in scrollview size and its content size.. might be they are equal in 4 inch screen... If they are equal, then there scrollview is not allow to scroll content.
Write only one line
scrollview.contentSize = CGSizeMake(320*[arrFields count],560);
here arrFields are an array which contains images.....use as per your need what you want to scroll
Related
I am making an iPad app
My app runs in all iPad screens fine but it is not working properly in iPad pro (12.9inch)
i know it can be solved by autolayout but, is there any other way to solve it without using autolayout ?
The best way is to use autoLayout however, if you do not want to use autoLayout then, you can manually check the size of the screen and as per the size, adjust the subview.
You would probably be better off just using autolayout. Its designed for this sort of problem. But if you really don't want to use autolayout for whatever reason you could lay your views out within some 1024 x 768 container view and do something like this:
let longSide = max(UIScreen.mainScreen().bounds.size.width,UIScreen.mainScreen().bounds.size.height)
if(longSide>1024){
//ipad pro
let scale:CGFloat = longSide/1024.0
containerView.transform = CGAffineTransformMakeScale(scale, scale);
}
You might have to set the center as well
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.
I created my application as tabbar application with iphone screens. It works well earlier. Now i want to change my tabbar application to support for iphone3.5 and 4 inch screen (in ios6 and ios7). In past i have designed only single xib for this.
is it possible to support all those screens with single xib? Please help me on this.
Notes:
I have latest xcode5. I have tried autoresizing , but it is very difficult to understand. Because its work for 3.5 inch screen and 4 inch screen in ios6 but view goes out of the screen in ios7.
That's not because of the size.
In iOS7 both top and bottom bars are transparent.. That's why your views get resized and covered by the bars.
To fix this simply add this lines to your viewDidLoad method:
if ([self respondsToSelector:#selector(setEdgesForExtendedLayout:)])
self.edgesForExtendedLayout = UIRectEdgeNone;
if ([self.tabBar respondsToSelector:#selector(setTranslucent:)])
self.tabBar.translucent = NO;
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.
How can i modify my code so same app can run on iphone with same UI elements.
I made changes in info Plist and made it universal but Problem is that i have not used stroryboard or nib , xib files to display UI elements. also i hardcoded the height and width for particular button or label ,frame etc.
So is there any way to auto resize screen to ipad view to iphone Or I need to write every code with new height and width for iPhone?
like in android i detect the height and width and according to that i divide it by 2 or 3 to place particular UI item on different screen size.
Also how can i detect that app is running on iphone 4 or iphone 5 or iPad so i can change my images and value or height n width?
You can get the screen bounds using:
[[UIScreen mainScreen] bounds];
The quantity of changes that you would have to make depends on how you designed your code before, if you were using absolute values all the times you'll have much more problems than if you were using relative values...
you can take a look at the UIViewAutoresizingMask property of your views, for example:
view.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
as to how to check if you are on iPhone 5 you can use this line of code :
BOOL isIPhone5 = [[UIScreen mainScreen ] bounds ].size.height == 568 ? YES : NO ;
Create seperate nibs for iphone and ipad
well doing it all codewise then you have to set the frame for all the components code wise checking the device is ipad or iphone.
Checking iPad or iPhone look here