iOS views presentation - iphone

Im new with iphone programming and im facing issues with the views.
I can not respent the view properly, for example in this case. I have an ViewController with a tabbar at the bottom. This controller have other 4 controllers where i show each of them when a user clicks on the icons.
But when a new view from one of the 4 controllers appears on the main controller, i get a line under the view. In the picture is a purple one.
When i change orientation, this empty line appears in the same place. Some times, when i enter with landscape orientation in the app, this line appears at the left.
I'm working here with IB. so, can someone point me here to the right direction? :S
On shouldAutorotateTo.. method i have YES, do i have to manage the views and change size and place every time the method is executed?
do i have to create 2 NIB for each controller, being one for each orientation option??
edit: i changed the picture to be more clear and show other "bug".
On 1 i enter to the view on portrait orientation. change it and still having a wear line up stares. All my nibs are on portrait orientation and 320 and 480 size.
On 2 i enter to the view on landscape but the nib loads as portrait. When i change orientation, it does not expand at it should.
How do i fix this 2nd issue?
i don't fill like having 2 nibs per controller :S
Thx in advance !

Short answer for Your autorotation problem:
You can either create two nibs (and switch between them, when autorotation occurs), or use just one nib. This depends on your goal. If you want to create a totally different view (like music app shows cover flow on landscape, and song on portrait) you should create two nibs.
If your view is more like the message app you could easily use just one nib. Take a look at the "Size Inspector" (5th tab in Xcode 4), the red lines guide you. The apple documentation for Xcode 4 interface builder is a good start to get you into that behavior.

That space in your view looks like the exact height of the status bar in iOS, review your NIBs in IB to see if you have a simulated status bar for your view controllers. If you do, turn it off and you will likely see that your view is not sized right. Being that it's height is 460 rather than 480.

Related

Xcode 5: Autosizing

I have the following problem:
I have a universal app. I use a tab bar, a navigation controller and a table view. There is nothing wrong, everything runs as it should.This is in Xcode 4.
But now I open the app in Xcode 5, something goes wrong. The view that comes after the table view, all have a text view. However, all text views are different in length.
In Xcode 4 I have properly set the autosizing for iphone / ipad. In Xcode 5 I have all the same settings. But the problem is that the text view is displayed differently. For short texts view begins at the top of the text. But for long texts, the view starts somewhere in the middle of the text. So I have to go up first to the beginning of the text to read. Also on the ipad, the view is not using the full width of the ipad to display the text anymore.
I have tried all of the autosizing, but I can not figure it out.
Check your constraints, you probably need to pin the height of the text views

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!

Xib Size - seems to think its longer than it is

This is a bit of a strange one, but basically I am having a problem whereby the xib size of my initial view controller seems to be longer than the screen.
So, if you have an ad banner set to be on the bottom of the screen... If I run the app in simulator, it does not show on iPhone 3GS/4/4S devices, yet WILL show on the iPhone 5.
I have tried changing the xib size settings, I even created a new xib file, but the same problem is occuring which leads me to believe it is hardcoded somewhere, but I cannot think where to look for this.
It is basically like it thinks the bottom of the screen is about 30-50px more than what it actually is... Hence why the iPhone5 displays ok as it has the taller screen.
Any help would be appreciated!
Its bcoz of the StatusBar. It reserve 20px of screen . You can remove this space by do change in Status bar is initially hidden in plist and set status bar to NONE in IB.
The iPhone 5 has a taller screen. The most flexible way to lay out your xib is via AutoLayout. Here is a tutorial to get you started:
http://www.raywenderlich.com/20881/beginning-auto-layout-part-1-of-2
http://www.raywenderlich.com/20897/beginning-auto-layout-part-2-of-2
Basically, you want the ad banner to be contrained to the bottom of the view.

presentModalViewController:animated:NO displaying 20 pixel gap

I begin with a view-based app template. In the automatically created viewcontroller's xib (call it VC1), I add a button, and define in its interface/implementation:
- (IBAction)showVC2;
- (IBAction)showVC2 {
[self presentModalViewController:[[VC2 alloc] init] animated:NO];
}
I then create VC2. In both implementations, I allow only landscape orientations. In both xibs, I set the views to landscape. In the info.plist file, I specify starting orientation as landscape right.
When I run the project in the simulator and press the button in VC1, VC2 is displayed, but a 20 pixel gap shows both on the lower edge and on the right edge. Notably, rotation causes the view to be placed correctly on screen after rotation completes.
This issue is similar to others:
1 2 3, though the solutions identified do not seem to work in the present case. The correct/expected behavior occurs if the modal view is presented with animation (I do not want the transition animated, however). This issue has persisted since last summer (iOS 3.1.3?). It continues with 4.3. The issue does not occur in portrait orientation.
Can anyone provide a solution or explanation for why such a simple modal viewcontroller presentation does not give the expected result?
EDIT: Xcode project
I just tried building what you suggested and have no problems with a gap. I don't know if there is a way for you to post all of your code or your project. If you can do that I will try and help.

Button has moved upwards when running app in Simulator

I have a strange problem when developing for the iPhone
There is one window (in green) and one view (in orange)
when I try to test my app it looks like this in the iPhone Simulator
you can see the view have moved upwards
is this normal? and how to solve the problem?
many thanks
You're most likely adding the view incorrectly. You could post some code and I could give you a better idea, or if you just want a quick fix, open the orange view in Interface Builder, make it 480 px tall instead of 460, show the simulated status bar and relayout your image.
In Interface Builder you can specify the simulated User interface elements. In the screenshots above you will notice in the green one you can see the status bar and the red one doesn't have it. You can turn on these elements by setting the properties of the view. Press Command-1 when you have the view selected and you will see a list of simulates ui elements you can add, these include the status bar, navigation controller bar and a few others i cant remember off the top of my head. This will allow you to position your ui elements correctly when you have these other elements on the screen.
The other issue with your view is that it is not the same height. have a look at the dimensions (cant remember exactly which one but its Command-2, 3 or 4 when you have the view selected) it should be 320x480, i reckon yours is 320x460... (20 pixels, the height of the status bar)