Size of UIView object in Interface Builder changes when using the app - iphone

I have an extra UIView object that I just dragged onto the storyboard. It covers the entire iPhone screen. So I clicked on it and dragged it until it only covered half of the iPhone screen.
This is what my storyboard looks like with my extra UIView object selected:
However, when I actually use the app on my iPhone, the UIView is much smaller and doesn't even take up half of the screen(It's the square with the stackoverflow site image inside of it):
How can I keep it from being smaller when I actually run the app? When running the app, I want the UIView object to be the same size as it is on the storyboard in xcode.
Thanks for the help.

You must have selected Autolayout. Uncheck it and problem is resolved.

Related

UIButton images look fine in IB but get stretched when displayed on app

I'm developing an Enterprise app for tracking mileage and maintenance for company vehicles. I've added graphic buttons to snazz it up a bit. The buttons look the way they're supposed to look on the XIB in IB, and on the iPhone all other UIViews look correct, but on one particular UIView the graphic images are stretched way out of proportion vertically.
The first image below shows how it's supposed to look, with the three graphics buttons at the bottom. The second image shows how it's showing on the phone. The Help button on this screen cap shows normally, but it can't be counted on to stay that way.
It also is not consistent. Calling this view at any time may show the image stretched or it may not show an image at all. It rarely shows the image normally, like the Help button looks below.
The development phone is a 4S running 6.1.3. The views are set for the Retina 3.5 screen. XCode is the latest (whatever it is).
Again, it's only on this one view that the problem shows up. There is another UIView on the same view controller that is hidden when this UIView is shown. The button graphics on the other view look fine. All of the other views and view controllers use the same graphics on the UIButton, without any problem.
In Interface Builder (Xcode) you created the view using a 4.5-inch screen height.
But the device where you are seeing the problem is a 5-inch screen. So the view is resized to fit.
And when it does that, the autolayout constraints that Interface Builder put on those subviews take over to determine what they do. Those constraints are causing the heights to change.
No need to turn Autolayout off. Autolayout can be very useful, but it seems to enjoy randomly assigning the constraint "Align Baseline to:" to UIButtons after repositioning them.
Just select the UIButton/UIImageView in question inside Storyboard, locate the constraint "Align Baseline to:", tap the gear icon and select "Promote to User Constraint", and tap once more and select "Delete". This should solve your issue.
In response to the comments here, I will answer my own question: I turned Autolayout off for this view controller, and that fixed everything. This is the first app I have written since XCode has begun development for the iPhone 5, so I wasn't aware of the Autolayout feature. I'll need to understand how it works and why it did what it did.
Thanks for all your help!

creating instruction screen in iOS

I often time see in an iOS apps when you first launch the app there will be a one time instruction with arrows and such to show a first time user guide. It's usually a black transparant colored screen with arrows. I was trying to find a few app that does this, but I couldn't. Was wondering if someone knew the terms for these and how to create it?
Create a UIView and place it above the view you're wishing to guide the user through. Set up the UIView as a IBOutlet in your classes header file, set the background to black and set the alpha to 0.3 or something similar (test to see how it looks).
In header:
IBOutlet UIView *overlayView;
In main:
overlayView.alpha = 0.3f;
You may want to make sure that the overlay shows the first time the users opens the app or maybe store a value in a database for when the user dismisses the screen so that you don't show it again. To do this you can hide the UIView or simply set the alpha to 0.
Then simply add images or annotations to the UIView. As "bentford" said it's quite broad but this should get you on your way. You can also use multiple UIView's or even transformations to animate the screens.
I use Skitch. You can find it in the Mac App Store.
Skitch can take the screenshot in the simulator and overlay the arrows and notes. Then when you launch the app, you show the image created with Skitch in a UIImageView on top of the actual view. Then just hide the UIImageView.

iPhone view won't scale to fit iPad screen

I'm having a bit of trouble with, as silly as all things, a progress view overlay.
I've created a subclass of UIViewController with a XIB with a black 50% opaque background and an activity indicator in the middle of it, I can get it to appeaer and disappear when my remote data class tries to get data from the remote server etc.
It works fine on the iPhone, scales and rotates.
However, when I fire it up in iPad simulator or on device, the square only fills the upper left corner of the screen and won't resize to to fit the display.
But, all my other views are created in the same way, including all the tableview's that this will sit over.
My app initialises a table view with a single cell that says "Loading..." and then calls the remote data services class which then does the following:
progress = [[ProgressActivityViewController alloc] initWithNibName:#"ProgressActivityViewController" bundle:nil];
UIViewController *dlg = (UIViewController *)self.delegate;
[dlg.view addSubview:progress.view];
NB: progress is set up in the .h file as ProgressActivityViewController)
It's the remote data services class that is adding and removing the subview, when you init the RemoteData class, you pass it 'self' as the delegate so it can talk to it through a protocol.
I know this needs some other type checking with 'isKindOfClass' etc which I can add in later but I need to get the simple view to stretch to full screen.
This code does work and puts the view on the screen but it just doesn't fill the screen on the iPad
The source for the activity indicator example i've used is at this link:
http://tapadoo.com/2009/iphone-how-to-do-full-screen-activity-status/
Do you have an iPad paradigm .xib in your project, and also listed that iPad xib file in your app's plist? If not, you may only get a window in the top left corner.
Create a new Universal iPhone/iPad project, and the template will show you where to mention the iPad xib in the plist.

Whats the approach to create a view similar to the one at apple app store

I wanted to know how can we design the view controller such that.., the upper half of the screen remains fixed and the below part of the screen can be navigated through.. !!
Should we use slipScreenController here ?
Your description sounds nothing like the Appstore app but the Appstore app simply has one vertical UIScrollView and another horizontal UIScrollView inside that for images.
If you are referring to browsing categories in AppStore then:
That is a tableView implemented in such way that it doesn't take the whole screen area. You need to create a UIViewController (not UITableViewController) and than add a tableView to the view (using Interface Builder or code). That way you can change the size and position of the tableView and use the remaining area of the view for something else, for example a UISegmentedControl above the tableView.
If you are reffering to reading description and images of single app then I think that UIScrollView is used for displaying images, not sure about the rest.

upgrade to universal app - size of mainWindow-iPad is 320x480

I have the following problem.
I have an iPhone app and want to upgrade to universal
When I do this, I get the expected MainWindow-iPad.xib.
But the size of the window is hardcoded to 320x480.
Also, there is no view in the window.
I red, this should be automatically iPad-sized, so I am assuming I am doing something wrong.
What exactly am I missing ?
thanks in advance
Yes, the dimensions of a UIWindow object are hard-coded to the size of the iPhone screen. This confused me, too, until I realized there was an option to resize it: select the UIWindow object in the .xib in Interface Builder... in the Attributes pane, make sure the "Full Screen at Launch" checkbox is checked.
As St3fan says you'll probably want to have a specific main window .xib for your iPad build.
See my answer at:
UITabBar unresponsive on iPad
I got this. I fixed it by deleting the automatically created ipad xib, then opening the original xib in interface builder and choosing convert to iPad from the menu. Then ni saved it with the -iPad name and added it to the corredt target.
You will probably also need to create a MainWindow-iphone.xib and MainWindow-ipad.xib.
I had a similar issue with a GLES application - using EAGLView, in a manner similar to all of the samples, but wanting to support iphone3,iphone4,and ipad.
in my context creation from [EAGLView initWithCoder], I was forcing the eaglLayer's rect to match the main screen, which worked for iphone and iphone4 (i.e. gave me a 320x480 or 640x960 gl surface), but for ipad, this gave me a 768x1024 surface which was cropped on present to 640x960.
As it turns out, The "Full Screen at Launch" option seems to be applied AFTER the view's (EAGLView, in my case) initWithCoder.
My solution was to do nothing in the [EAGLView initWithCoder], and only actually initialize my view after the AppDelegate's didFinishLaunchingWithOptions gets called, in the layoutSubviews call.
HTH,
forks