UISplitViewController - BarButton Item not shown at start - objective-c

I'm having trouble showing a UISplitViewController programatically.
I have two views, a UIView with buttons which when are pressed load my own custom RootViewController and DetailViewControllers into SplitViewController and then hides the menuSubview for showing UISplitViewController.
Well, it works well in portrait orientation, but when the view is shown the barButtonItem associated with the popOverViewController is not shown. After if I change orientation to landscape, then back to portrait again, the button appears.
Why does this happen? Is there any way to fix it?
I have a little idea. When splitviewController.view is added to the window, the root and detail view controllers are not set yet so could that be the cause?

Well at last I solved the error.
Instead adding two subviews and show/hide them, I add my splitViewController.view as principal to the window and presented the menuViewController as modal, so this issue was solved.

Related

UINavigationItem Prompt Animation Issue

I have two UITableViewControllers that are connected via a Show segue. The prompt property of UINavigationItem is set on both view controllers in Interface Builder. When the first view controller is shown, the prompt and navigation bar are both displayed properly, however, when performing a segue to the second view controller, the title and the back button animate undesirably. I have tried setting the prompts programmatically in the viewWillLayoutSubviews, viewDidLayoutSubviews, viewDidLoad, viewWillAppear:, and the viewDidAppear: methods of both view controllers, but I get the same effect.
Any ideas on how to resolve this issue? I don't want to resort to a custom view for the titleView because I prefer the stock functionality, but I am not able to figure out how to fix the undesirable animation.
Here is a video if the animation in question.
Well, it looks like this is an issue with the way that the UINavigationItem is laid out when showing the next view controller.
According to Catalina T. in an answer to a similar question, making two calls to set the hidden property of the navigation bar to true and then again to false in viewWillAppear: seems to get by this issue.

How do automatically resize an NSPopover with auto layout

I currently have an NSPopover subclass which sets it content view controller to a custom NSViewController meant to represent a tab view:
self.popover.contentViewController = tabViewController;
self.popover.animates = YES;
I'm rolling my own "tab view controller" because I've heard that NSTabViewController doesn't play well with animations. I'd like to use auto layout so I don't think I want to mess around with the popover's contentSize property. When I change tabs the popover correctly changes its size, however, it doesn't animate the change. Furthermore, I have a cross-fade animation that occurs when the tab view switches and the popover doesn't resize until after the animation finishes.
First, I'd like to figure out how to get the popover resize to animate and then I'll worry about getting the animation in sync.
Thanks

ios7 custom VC Transition: Overlap a Modal Form Sheet View

i want to use the new UIVC Custom Transition API in my iPad App Project. And i despair of it -.-. what i want to do, sounds very simple at first. My "FirstViewController" (simply the names) is a normal FullScreenVC. From that VC i open a "SecondViewController"modally with the default Presentation style Form Sheet. Everything allright. The SecondViewController is a normal UiTableViewController. So from inside the SecondViewController I want to open a "ThirdViewController" modally as well with a custom transition. This ThridViewController have to overlap the SecondVC with the Form Sheet Presentation and the content of the second view controller have to be dimmed as well. But i get many problems inside the animateTransition-method in the the Transition Delegate. My best idea by now is, making a UIView Snapshot of the from View. Create a new UIView with black background and alpha 0.5 and put it as a subview inside UIView Snapshot. Then transfer the frame and the center of the fromView to the toView and add the UIViewSnappshot as a subview to the toView and send it to the back. finally adding the toView to the containerView.
But when i do this, I get two s*** problems. The First is, that the Transition don't recognize that i am using a Retina display, because i put the center of the fromView to the the toView. But the toView dont overlap the fromView, better its nit at the same postion. Its almost at the left down of the screen and not in the middle of the screen. The second problem is, that the toView content seems to be transculent. In Storyboard and in code i write "be opaque and white bgcolor". But at runtime the see the controls of the view but the bgcolor is the bgcolor of the dimmed View behind it. Why?
At the moment i think i'm a dump guy :( What in hell im doing wrong?
Thanks
Avarlon

Only subviews added in viewDidLoad automatically resize

I've created a custom subclass of UIViewController that acts like a UINavigationController or a UITabBarController. Let's call it a ToolbarNavController. It has a toolbar at the bottom with controls for the user to move to a different content view.
I have two content views aside from the ToolbarNavController's view. Both are loaded from a nib and have their own controllers. The app starts out showing one of them. A button in the toolbar allows the user to switch between them.
When I add these views as subviews of the ToolbarNavController's views in viewDidLoad, they are correctly resized to fill the area between the status bar and the toolbar without overlap/underlap.
But when I try to lazy load the second view, adding it as a subview for the first time only when the user presses the toolbar button, iOS does not resize the view to account for the toolbar in its parent view, and it underlaps the toolbar which messes up my Autolayout constraints. Also, when I don't add the subview in viewDidLoad, if I put the device in landscape orientation before switching to the second view, it loads with a portrait orientation frame.
Bottom line: When inserting a subview in viewDidLoad, iOS sizes it correctly and manages autorotation for it. When inserting it later, I need to detect orientation set the frame myself. (And for some reason when I do this, autorotation kicks in again).
What is going on?
In viewDidLoad, the view is not yet layout for the resolution and interface orientation, and view properties are as they were in the interface designer. So, if you had a portrait view, that is how the initial properties of the view are set when going into viewDidLoad. When you add your view there, you add it to the XIB view. Later, iOS performs layout on the view hierarchy and thus resizes your inserted view as needed. But when adding your view at a later point, the view hierarchy has already been layout, so it is expected that the new view you are adding is also layout correctly.
Best practice is to calculate the size you need using the size of the view you are inserting into. For example, half the width of the containing view, or third the bounds, etc. This way it is independent on the orientation the interface is in.

presentPopoverFromRect is displaying a popover sideways on rotation

-I have a UIView.
-This UIView has a UIButton that when clicked makes a UIAlertView appear.
-Within this UIAlertView I have another UIButton that when clicked calls buttonClicked:
-Within this buttonClicked: method, I call presentPopoverFromRect with a custom view inside. (hourKeyboard is the custom view)
-(void)buttonClicked:(id)sender
{
if(self.hourKeyboard==nil)
{
self.hourKeyboard = [[HourKeyboardViewController alloc] init];
self.hourKeyboardPopover = [[UIPopoverController alloc] initWithContentViewController:self.hourKeyboard];
}
[self.hourKeyboardPopover presentPopoverFromRect:[sender bounds] inView:sender permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];
}
In normal portrait mode, this works great. The popover spawns just to the right of the button, with the arrow correctly pointing left to the button.
There's 2 problems that arrises:
1) While this popover is visible, when you rotate the screen the popover rotates slightly incorrectly (it doesn't reposition it's own x and y position)
2) If the popover is not being shown. If you rotate the screen, then call "buttonClicked", the popover will appear, however, its being shown sideways above the button with the arrow pointing "down" towards the button (technically left in relation to the sideways popover view). If you dismiss it, rotate the screen, then call "buttonClicked", the popover now appears upside down with the button pointing "right" to the button (again, technically left in relation to the sideways popover view)! Repeat to make it sideways again, then right-side up again.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
My thinking:
1) I believe I can just reposition the x and y, however, I've also read that you should dismiss the popover and present it over again on a rotation. I'll see if I can get the first one working, however I'm more concerned about the second problem.
2) I have no idea how to fix this rotation issue. It seems that when you rotate to landscape without the popover being visible. And then you call presentPopoverFromRect, the popover is created with the iPad thinking it's still in portrait view by mistake. That's the behavior it's giving, however, I'm not sure how to make the iPad not make this mistake.
-=-=-=-=-=-=-=-=-=
Thanks again for any help you can provide!
-=-=-
Slight Update:
1) It was easy to just dismiss the popover from the main view on rotation. And this seems to be the general way everyone deals with this issue.
2) Trying out various things such as changing the frame, using CGAffineTransformMakeRotation, and others...but no luck thus far
-=-=-
Another Update:
2) After a lot of testing, it seems to be a direct issue with UIAlertView. If I place the view within UIAlertView (currently doing), the AlertView doesn't tell the popover that the screen is rotated...thus creating the issue
It looks like the only way to fix this is to drop the UIAlertView completely. Instead of showing the UIAlertView, I'll disable the various background views manually (like Alert View was doing) and then show a custom UIView that looks darn similar to the AlertView. From there, I should be able to show the popover without any issues. I'll let yea know how it turns out.
-=-=-=-=-=-=-=-
Final Solution:
I ended up just creating my own view, and having that view imitate a UIAlertView. Then when I spawned the popover, I placed it in the root view controller. Worked much MUCH better, but required more work since I had to manually create my own View instead of the premade UIAlertView. Either way, apparently UIAlertView fails at telling a UIPopoverover subview what rotation it is in.
dismiss the popover in willRotateToInterfaceOrientation and show it again in didRotateFromInterfaceOrientation.
It works with no problems.
EDIT:
Sorry, I misunderstood your second problem.
If some part of your view hierarchy is displayed with bad orientation, one of your controllers is probably missing shouldAutorotateToInterfaceOrientation method.