I am trying to resize the view but not working,
I have UIView in CustomCell, its working in iphone 5S but when i check in iPhone6 or iphone6+ simulator than its not changing the size of UIViews.
cell.ViewImgWithOption.frame= CGRectMake(0, 0, WIDTH,60);
Above code working in 320 size screen Width but not working in 375 or 414 size screen Width.
Any suggestion?
try this one hope it will work.
cell.ViewImgWithOption.frame= CGRectMake(0, 0,self.view.frame.size.width,60);
Related
I have an app that is using a UITabBar and UINavigationBar. I am creating a UIImageView that contains my background image and then add that UIImageView to my self.view as a subview. This causes the background to appear "squished" vertically. The background image is not starting until the bottom of the NavBar and then runs down behind the TabBar.
Here's the code I'm using to add the background:
UIImageView* backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"background.png"]];
[backgroundView setFrame:CGRectMake(0, 0, 320, 480)];
[self.view addSubview:backgroundView];
Any ideas about how to keep the actual size of the background would be greatly appreciated.
First off, you won't have 480 points of height to use with a UINavigationBar present on anything less than an iPhone/iPod 5. You should use self.view.frame.size.height to get the actual size. Really, you should just set the frame to the view's bounds.
[backgroundView setFrame:self.view.bounds];
Secondly, you should set the contentMode property of the UIImageView.
[backgroundView setContentMode:UIViewContentModeScaleAspectFill]; //Set UIViewContentModeScaleAspectFit if you want to show the full image with the potential of a letterbox
That should solve your problems.
I'm not quite sure what you're asking. Yes, any view that belongs to a tab bar controller or navigation controller will be resized to fit the remaining screen space, but you know exactly how much space your image view will have left after considering the space consumed by the other UI elements:
Status bar: 320 x 20 (portrait), 480 x 20 (landscape) Navigation bar: 320 x 44 (portrait), 480 x 34 (landscape) Tab bar: 320 x 49 (portrait), 480 x 49 (landscape)
So basically, you have the following available space for your image view:
Portrait: 320 x 367 Landspace: 480 x 217
Design your Default.png with those dimensions in mind. Honestly, the easiest way to match your first screen with your Default.png is to simply take a screenshot of the iOS Simulator.
I have a 850x1100 UIView defined in a storyboard it is 4 times the size of a normal window, and I'm using it as a PDF generation template.
The view is wrapped within a scrollview. Yet when I display the view, its frame gets resized and becomes 320x460, effectively cutting off everything outside the frame.
Does anyone have insight on why my UIView defined in a storyboard as 850x1100 gets its frame reset to 320x460 when displayed on an iPhone?
This frame recalculation is not a bug. The frame of a view represents its position and size relative to the screen coordinates.
The iPhone viewing area is 320x480 and any view that has its frame set to a CGRect larger than the viewing area of the device will become "clipped" and have its frame set back to the viewing area (320x460 viewing area due to the status bar).
Try:
scrollView.contentSize = CGSizeMake(850,1100);
scrollView.clipsToBounds = NO;
pdfView.clipsToBounds = NO;
Are you sure it's not the scrollview whose contentsize is too small? It won't automatically resize based on the content - you have to explicitly set the contentSize of the UIScrollView
I have a UIView of size width=320px height=40px which I want to display at the bottom looking like a tab-bar.
I use the following code to accomplish this and it works fine on iPhone. But when I try the iPad simulator, the view does not appear anywhere on the screen.
buttonsView.frame=CGRectMake(
0,
self.view.frame.size.height - buttonsView.frame.size.height,
self.view.frame.size.width,
buttonsView.frame.size.height );
This stretches the view to the width of the screen but keeps it's original height.
How can I make this show right on my iPad also?
[UPDATE]
This happens in my viewDidLoad.
I have this NSLog now:
NSLog(#"buttonsView Width: \t%g\t%g\tHeight:\t%g\t%g",self.view.frame.size.width, buttonsView.frame.size.width, self.view.frame.size.height, buttonsView.frame.size.height);
With output:
iPhone:
buttonsView Width: 320 320 Height: 460 40
iPad:
buttonsView Width: 768 768 Height: 1004 40
I also create another view like this for the top of the page which works fine:
dataView.frame=CGRectMake(
0,
0,
self.view.frame.size.width,
dataView.frame.size.height);
Have you looked (using breakpoints or NSLog) at the values you are putting into the CGRectMake call, just as a sort of "sanity check"?
Thanks for the info. My next thought is that between viewDidLoad and viewWillAppear something is being changed by the OS. Perhaps try moving the code to viewWillAppear so that you are guaranteed the frames you are working with will be the frames that will be displayed. This Stack Overflow answer explains it in a little bit more depth.
This happened because the Auto Resizing was set for the UIView's.
To fix, set the Auto Resizing to bind it to the top left corner. This way whenever you change the frame, it is relative to the top left pixel.
This is the problem that I have:
I have an UIImageView inside an UIView.
Then I rotate the UIImageView 45 degrees using gestureRecognizers with 2 fingers.
Everything seem good now but when I start resize the UIView about -10px width, height by changing the UIView's frame, the UIImageView become very ugly, it does not resize with ratio.
It become stretch.
It does not happen when I rotate the image with 90 or 180 or 270 degrees. the UIImage resize OK.
Sorry for my bad English.
Tung Do
Redraw the image after the pinch.
I am adding a bunch of boxes into a UIView inside of a UIScrollerView. The content of the UIView goes beyond the bottom of the device's screen and should cause the whole scene to scroll.
However, this isn't happening. The content gets added but the scene will not scroll. I assume it has to do with UIKit not automatically resizing the UIView container to match the overflowed content (I can understand why), so I tried setting the new bounds rectangle with [container setBounds: CGRectMake(0, 90, 768, 230*20)], with the 20 being the number of boxes (the height of each is 230). When I do this, nothing appears at all...
Anyone know why the content doesn't reappear or does anyone have another solution for making the UIScrollView scroll?
You should set the contentSize of scrollview, to match your UIView's size.
Please see
http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIScrollView_Class/Reference/UIScrollView.html#//apple_ref/occ/instp/UIScrollView/contentSize