I'm building my iphone app.
I've got a problem. For every view without the Navigation bar and the Tab bar is pulled up of 20px.
So I have to place every elements 20px below the top edge.
In this screenshot http://ge.tt/4FG1fJ9 you see the Interface builder view, with 20px bar space at the top, and the result into the Simulator.
This solution works, but give me some problems, and it's not elegant.
I'm wondering why all this happens.
Have you got any idea?
Thanks
In Interface Builder, open your xib, click on the root UIView and then hit Cmd-1. That will bring you to the UIView Attributes window. There are a few drop downs for "Simulated UI Elements" and you can set the Status Bar to Black (or whatever the option is). This doesn't add the status bar to your view, it just simulates the size of the status bar so that you can layout your views without having to shift everything down by 20 pixels.
This is a common problem that seems to rear it's head in different ways. The cause, though, usually has to do with poor coordination of the status bar.
I was able to reproduce the problem just now in a test app by adding a 'Status bar is initially hidden' line to my Info.plist and setting it to YES. The app looks fine in the main view, but if I push a new view controller and then set the status bar to display, the new view appears shifted down 20px. That is, the top of the view appears 20px below the bottom of the status bar.
I know that's not a terribly specific answer, but take a look at how you're hiding/showing the status bar in your app, and also how you have the simulated status bar in your .xib files set.
Related
I'm really getting extremely mad with Xcode, trying to get a ScrollView correctly working. I'm having in fact 2 problems, but I'll separate it in two questions.
First of all, check out this screenshot.
Whether I drag the ScrollView to the top of view or just to the bottom border of the navigation bar, the web view (white square) stays about 60px from the nav bar, as you can see in the simulator.
The only way for me to have the web view aligned just below the nav bar is by dragging the Scrollview to the top of the view, at the top of the nav bar, and dragging the web view all the way to the top too.. Which places (in Storyboard) the web view behind the nav bar. Seems a bit odd, isn't it? The web view object has no attributes assigned to it which could have created that strange space.
What am I doing wrong?
Note: I have less than 40 hours of Xcode experience resulting in knowing nothing of Objective-C lines, but the Xcode interface itself. Learning by tutorials and practice
In the view controller add this method...
- (BOOL) automaticallyAdjustsScrollViewInsets
{
return NO;
}
This will fix it for you.
I built my project as a Tab Bar Application that utilizes the UITabBarController.
I've set all the auto layout constraints for all my subviews and it looks right in the preview. When my application first starts, I hide the tab bar in viewDidLoad. Once a button is clicked, I hide the view and show the tab bar.
My problem is that the constraints adjusted themselves to the hidden tool bar and everything shifts down the length of the height of the tab bar. If I go to the second tab and back to the first, the constraints are back to normal. Is there an easy way to deal with this? I need to find out how to either hide the tab bar in other way that doesn't compromise my constraints, or how to allow the first view to extend down over the tab bar. Please help.
Hiding tab bar liks so.
[self.tabBarController.tabBar setHidden:YES];
Oddly enough. When I go to set the vertical constraint to the bottom of the view, the distance to the bottom of the view is equal to the top of the tab bar even though the height of the tab bar is 50 px.
This is not my day. I've just deleted every object from my previously completed view controller to start over because I can't get a simple scroll view to scroll. I've got a view controller that is embedded in a navigation controller. I put scroll view inside the view controller and then put two text fields inside the scroll view, one field at the top and one at the bottom.
First of all, when I run this, it won't scroll. What is the point of the scroll view if it won't scroll?
Second, I can't figure out how the relationship between the navigation bar and the scroll view works. Is the scroll view behind the navigation bar? Is it below the navigation bar? In the story board, it looks like it is behind the bar, but when I run it, my text field is pushed down so far that it looks like it is behind it.
Here are a couple of screen shots. To say that I am frustrated is an understatement. Thanks for any help getting me out of my circular problem. I appreciate it.
And here is how it looks when I run it. Notice how far down the top text field gets drawn. Also note that you cannot see the bottom text field. I am unable to scroll to this. What gives?
First of all, when I run this, it won't scroll. What is the point of the scroll view if it won't scroll?
Scroll views won't scroll by default unless their contentSize exceeds their bounds. You can force it to scroll anyway by setting alwaysBounceVertical to YES.
Second, I can't figure out how the relationship between the navigation bar and the scroll view works. Is the scroll view behind the navigation bar? Is it below the navigation bar? In the story board, it looks like it is behind the bar, but when I run it, my text field is pushed down so far that it looks like it is behind it.
Yes, in iOS 7, by default, a scroll view will start at y = 0, behind the nav bar. You use the contentInsets property to push it down. The view controller has an automaticallyAdjustsScrollViewInsets property that can handle this for you.
Can anyone please tell me how to fix the following issue.
I am building an iPhone app using Storyboard. I have a Navigation Controller as root view and off that a view controller. On this I have a few buttons that when clicked takes you to a table view controller. All fine and well, but when I link the buttons to their respective table views, the top navigation bar obscures the top cell in the table view controller.
Does anyone know why this is happening and how I can fix it?
Also it seems to have thrown off my layouts from the view controller from which they inherit.
See attached image for a better explanation perhaps.
I believe this is the intended behavior when using the translucent navigation bar. It's semi transparent specifically so that you can see items pass behind it (e.g. a table scrolling). If you don't want this, changing the navigation bar's style to opaque should solve the problem.
Since I wanted to keep the translucence, I just added a UIView between the navigation controller and the prototype cell (width of the view, height 60). That way the first cell in the table starts beneath the navigation bar but I can still see the scrolling underneath.
This is a bug/feature in IB when you use a translucent navigation bar, the content view runs under the navigation bar. For non transparent bars the content view begins after the bar. If your content view is a UIScrollView (UITableView is a descendent of UIScrollView) the content will be automatically scrolled so as to not be hidden under the navigation bar. So the problem only exist in IB when you run the app everything should be ok.
You just need go to the Navigation Controller properties, then Simulated Metrics, and change the Top Bar to be a Transluscent Navigation Bar WITH PROMPT. And that should be it. No need for that extra UIView
I'm currently working on a MonoTouch application with a NavigationController, a root view with some ImageViews in it and some standard and customized/subclassed TableViews and TableViewCells. Some elements are located in xib files, others are code only.
Navigation and table contents itself work fine. However, I suffer some weird "animation" effects... I'm trying my best to describe them as good as possible.
1)
When navigating back and forth on the navigation stack, each time a view appears, it looks like the items of that view are re-layouted. When navigating from a subview back to the root view, it's ImageViews start off at some location where they shouldn't be and slide to the right location.
2)
TableViewCells "unfold/reveal" their content from top to bottom when appearing in the visible area, even when reloading without animation:
TableView.ReloadSections(new NSIndexSet(1), UITableViewRowAnimation.None);
Scrolling down the table, each cell seems to trigger it's own "unfolding" animation separately as soon as it becomes visible.
3)
Scroll bars of TableViews slide from view to view.
For example, when tapping a cell that pushes another TableView on the stack:
- Parent table slides out to the left / sub-table slides in from the right (as it should)
- When sub-table has fully appeared, it's visible cells "unfold" from top (of the table) to bottom
- Finally, when this weird cell unfolding has finished, the scroll bar slides in from the left (where the parent table "is") to it's correct location on the right side. So it looks like it is reusing the scroll bar of the parent table.
4)
When displaying the network activity indicator...
UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
... it appears where the network carrier name is (left-most on the status bar) and slides to it's intended location (next to signal strength indicator). The same happens to the "You are being located" arrow. When starting a LocationManager, the arrow appears on the carrier name and slides to the right.
All this animation and slide action is really irritating and distracting.
I checked on some other MonoTouch apps on the AppStore, none are suffering from this.
What have I done wrong with my application?
I'm really grateful for hints on what might cause this weird behavior and how to disable it.
I had this just today - I'd performed some animations in my app using
UIView.BeginAnimations("AnimationName");
UIView.SetAnimationDuration(0.5f);
// and so on...
and it turns out I hadn't actually committed my animations (using:
UIView.CommitAnimations();
ensuring I had called CommitAnimations() got rid of this behaviour!