I have a splitviewController for my iPad app that uses a uinavigationcontroller in its detail view (right view controller). Everything is hooked up in interface builder and after calling:
[self.window addSubview: splitViewCpntroller.view]
I get the left and right views to display.
The problem is, the navigation bar's y position in my right view is wrong and offset a bit (I think 20px) downwards so that there is a gap between the status bar and the right view's navigation bar.
I've spent the whole afternoon trying to figure out what's wrong but I didn't find anything. Since its all hooked up in IB I can't show you much code.
I'm sure it's a simple thing I'm missing and since it's IB it's probably hard for you to follow what exactly I was doing - but maybe one of you encountered this before?
This is one of those questions that comes up pretty often, but for some reason it's hard to remember the answer. However, I think the root of your problem is that your view controller's view has a height that's too small -- try adding 20 pixels to the height, and also check its position.
Related
I've found a problem in my OSX app that I think is a Mavericks bug.
I have the following hierarchy:
NSView
->NSScrollView
->NSClipView
->NSTableView
When the scroll view doesn't contain any records I'm creating an overlay view as a subview of the NSView, and positioning it above the other subviews. I do this using:
[containerView addSubview:overlay
positioned:NSWindowAbove
relativeTo:nil];
FYI, the overlay view is a custom NSView subclass with a drawRect to draw the overlay itself.
On Mountain Lion this works fine, but on Mavericks the overlay does not appear. Googling around I think this is because the overlay is not being positioned above the other sibling views.
I found these links for reference:
Display Order Messed Up
Maverick Issue When Adding Subview on NSView (Stack Overflow)
The second link suggests the following code to fix the issue, which it appears to do, but as I don't have any layer-backed views in my app this feels a bit off:
[overlay setWantsLayer:YES];
Can anyone suggest a workaround for this problem other than the one suggested?
EDIT: I've found that if I put an Xcode breakpoint in the original code (without the workaround) at the point after the subview is added the subviews get added correctly, and my overlay view is displayed. If I remove the breakpoint, the overlay view is no longer displayed. Does this behaviour indicate anything?
Thanks
Darren.
It looks like you've been bitten by overlapping views:
Note: For performance reasons, Cocoa does not enforce clipping among sibling views or guarantee correct invalidation and drawing behavior when sibling views overlap. If you want a view to be drawn in front of another view, you should make the front view a subview (or descendant) of the rear view.
from Apple's Working With A View Heirarchy.
As you note, the common recommendation to fix this is to is to set a layer. However since 10.4 you can hide a view using setHidden:, see Hiding Views in the above reference. This may solve your particular problem as your overlap appears to be total (you don't want to see parts of both views, only one of them).
HTH
I'm new on iOS Development and I already searched Google many times but didn't find a solution to my problem.
I have a UITabBar that has two tabs. The first one shows a ScrollView with some UIViews in it.
If I scroll the content (the UIViews), then change to the second tab and change back to the first tab, the UIViews get its origin point changed.
I'm using NSLog() to show the origin point of the UIViews in the viewDidAppear method of my UIViewController.
When the view appear the first time, the origin point of the UIView is (0,0). After changing the tab and changing back to the first tab, the origin point is set to (0,-XXX) where XXX is negative and varies depending on how much I have scrolled the content initially.
Can anyone help me, please?
This is a known bug with UIScrollViews and the autolayout system. If you reset the contentOffset in -viewWillAppear you can work around it:
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.scrollView setContentOffset:CGPointZero animated:NO];
}
Problem solved.
I couldn't test the solution of resetting the contentOffset because i already changed my interface.
Instead of adding the UIViews with the storyboard tools, i'm adding dinamically in the code.
That prevents me from others problems that i was having...
Anyway, thanks guys..
I have a UINavigationController within a UITabBarController. Within the navigation controller I have a ViewController that looks after flipping between two views using transitionWithView:duration:options:animations:completion one of the views i am trying to show is a TableView.
The problem is when showing the TableView it is off position.
and the flip view
I have tested flipping between two standard views without issue, it is only the TableView that shows off position. Also when the Tableview has more data then can be shown on screen the bottom rows are hidden by the Tabbar. It looks like the frame size is wrong but I am not sure how to proceed to fix the problem.
Full test project and code can be found on GitHub
Any suggestions or help is greatly appreciated.
The root of the problem is that you are using UIViewControllers (FlipSide and FlipMain) as subviews for FlipController which is itself a UIViewController. Prior to iOS 5 this was not supported and inevitably led to problems. iOS 5 adds support for a view controller hierarchy but requires that you use the appropriate new methods.
You have a couple of choices: restructure the view controllers so they are not nested, rewrite the sub-controllers as UIViews, or use addChildViewController to add the subcontrollers.
I've forked and modified your original code here to illustrate that changing to UIViews resolves the problem with layout.
It's a bit hard to answer without the full code, but I would try playing with the "wantsFullScreenLayout" property of your view controllers. I say that because the offset seems to be 20px high, which corresponds to the status bar's height...
Let me know if this helped ;-)
I am playing a little with the split view of iPad and I want to add different views to the rootView of the split. I can add one image, one view of one of my view controllers but, instead of that, I have problems with de rotations.
For example, sometimes appear a white bar on the top and I can't do anything to move it. Does someones know how to add views to the rootView perfectly? Is this correct or I have to make other things.
Thanks
David
Finally I resolve the problem: When I dismiss the popover I have to get out the animation. If I do this, all works fine.
But if someone can tell me the best practices to how to put views in root controller please :)
I'm currently using UISplitViewController as my app's rootViewController. To present progress dialogs I use presentModalViewController, but for the one and other reason I'm not entirely happy with it and want to do my own modal thing.
If one of my modal views is supposed to be shown, I want to add another subview to my app's main window. This subview is going to be managed by its own UIViewController subclass to make it rotate properly and do all the stuff I need.
Is this design aproach okay or will I run into issues with UISplitViewController (it is very special in so many ways and seems to be offended easily if not treaten right! :-))?
Is it a problem to have two UIViewControllers next to each other?
Please don't discuss "why don't you use presentModalViewController then?".
You may be ok with UISplitViewController if you do it properly, as presentModalViewController does something similar.
One alternative you should look into is UIPopoverController and the UIViewController's modalIfPopover property.
Also, you say you aren't happy with presentModalViewController and perhaps if you say what was wrong with it we can help you work around whatever issues you have with it. This is the exact case that it seems to be meant for.