xcode two uitabbarcontrollers one page. auto-rotate issue - xcode

Summery:
I have a custom UITabBarAutoRotateController which returns YES from shouldAutorotateToInterfaceOrientation. This has no effect.
If I minimize and show the app again, the rotation issue goes away.
How do I refresh the screen so the user does not have to do this (so rotation works again)?
Details (setup graphically, so no code):
I have two UITabBarController in MainWindow.xib. I only want one to show at a time. So I am linking graphically rootViewController = tabBarController_name1. There is also tabBarController_name2.
I will also have an alert MessageBox for a user to choose what type of application they need, and it will choose a tab bar controller based on their request (per customer definition). This is commented out for now.
There is a bug with Rotation when two UITabBarControllers exist on the same xib. When I try to rotate the screen, it stays upward with wherever the main screen button (power button looking button) faces. HandleOrientationChange does not get called on the active custom ViewController being shown.
The reason I believe it's a bug is because if I hit the main screen button (minimizing the application), and click back on the application (brings it back to the foreground), rotation works perfectly!
Sorry for making you read all that mumbo :). My true question is, "Is there anyway I could refresh the main window or likewise UITabBarController's to get rotation working (without requiring the program be minimized and shown)"? A work-around, if you will?
p.s. I cannot use Storyboard for backwards compatibility reasons. The customer will be receiving this code/project. So I would like to keep this in one graphical page, rather than hiding/showing UITabBarItem's.
EDIT: two-uitabbarcontrollers-and-autorotation and uitabbarcontrollers-and-uinavigationcontrollers were both helpful, but did not address "why" this issue happens. "noob" here when it comes to xcode :)

Tab bar controller inside a navigation controller, or sharing a navigation root view is the answer. Do not use a TabBarViewController. Which, as a noob, I'm not quite sure why TabBarViewController exists (or at least isn't depreciated).
Dragging two TabBarViewControllers into the same page should result in a warning saying that you probably want to implement TabBarViewController by making a custom UIViewController and attaching a plain UITabBar to it.
Frustrating...but finally making progress :)

Related

Xcode 6.1.1 StoryBoard Size

Good morning,
I am new to Xcode and am learning to create iOS applications.
When I open a single view application and click on main.storyboard, my size is w Any h Any. When I decide to add a label and run the iOS simulator (iPhone 6 or iPhone 5S), the label appears somewhere else.
This is really frustrating and I have tried many approaches such as disabling use size classes, changing the storyboard size by clicking the w Any h Any button, and even messing with the constraints as mentioned here: Xcode 6 Storyboard the wrong size?
I am really trying to continue with this but I have seem to hit a wall for a couple of hours now, if someone could shed some light to why I am messing this up, that would be amazing.
EDIT: How can I get it to be a "normal" sized iPhone, such as the iPhone 5s?
You can click on the w Any h Any to change it to a normal iphone size by mousing over the squares and reading which devices they encompass.
You are going to have to use constraints though in order to make anything go where you want it to, I really didn't want to learn them but I couldn't do without them now: they are very useful.
EDIT
Constraints are simple in concept but can be tricky in certain situations:
For any view to have valid constraints that work correctly, it needs to know what the size of the view is and its position in it's "parent container" which is just whatever view or viewController it is inside of.
The little |-O-| shaped button and its neighboring buttons next to "w Any h Any" give you options for positioning and sizing the view. So if you click on a view and then click on that square button in the middle, check the width, height boxes and click the left and top lines in that top positioning thing with sizes in it like so:
Then click on add 4 constraints. You will notice blue lines appear around your view saying that it can properly put it where it needs to go when running the app. If there is any orange or red that means there are conflicting constraints on the view.
Sometimes that can mean you put to many constraints (more than you need) and you just need to delete them in size inspector tab. But more often than not, if that doesn't fix it, I've noticed that I usually have a neighboring view that isn't properly "constrained" and is actually the cause for the other views problems.
How can I get it to be a "normal" sized iPhone, such as the iPhone 5s
You don't. The view controller's main view will be resized correctly when the app runs (on a device or in the simulator), as appropriate for the device type and other aspects of its surroundings.
Your job is to use auto layout so that no matter how the view is resized, its subviews (labels and buttons and so forth) will look good. That is what auto layout is for - it's to help you compensate for the fact that you have no idea what the real size of this view will be at runtime.

Split View Controller showing only one view (Xcode 6)

I'm trying to get the split view controller working properly but apparently there's a bug in there or I'm missing something.
First of all, I've started a blank OSX Obj-C application, and in the Storyboard I've dragged the split view controller. Next, I've linked the segues from the main window controller to the split view and added two labels.
http://i.imgur.com/dlFObaF.png
When I build the project, it shows only the second page. Not to mention strange window size in the final build.
http://i.stack.imgur.com/IqRqr.png
I've tried everything.
This occurs in both vertical and horizontal split view.
Any suggestions?
I had the same issue myself today, but it's just the split line wasn't initiated properly.
To see, this, once you run your app, move your mouse toward the edge of the window and drag it, you will now see another view emerging.
To my best knowledge, I do not know how to fix this in IB or in code. Apparently NSSplitViewController does not have a property like UISplitViewControllerAutomaticDimension. Would appreciate if someone can contribute to this.
Edited: Found an answer via another thread. Basically, try to add some constraints to the subviews inside each view and that should prevent the size of a view to be zero. In my toy example, adding margin constraints to my buttons worked out well.

IOS/Xcode: storyboard screen turning black

I am just learning Xcode. I did something that caused a view controller to turn black below the navigation bar when you build app.
It looks white in storyboard.
Also, when I pull a label onto the storyboard, it aligns to the left margin and does not show the drag boxes around it.
I may have inadvertently clicked something but when I compared it in attributes and identity inspectors line by line to another project, nothing seems amiss, i.e. everything is the default value.
Has anyone run across this?
There is not code in associated class that would cause this as it is generic i.e. plain vanilla.
Would appreciate any suggestions. Thx.
With that little information i'd say you removed the root view of the controller?
Either way, you say there is no code, so I'd suggest you simply delete that controller and create another one (bottom right, objects, viewcontroller). Since it's empty you're not gonna lose any data or time :)
Then link it to your class in the Identity Inspector and you're good to go as if it was a new one.

Prevent or change direction of animation in NCWidgetListViewController

I am trying to create a Today Widget in Swift with XCode. I started with the available example code of XCode, when you create a new Today Widget target. The content of my Today widget is loaded from an external source, and whenever a new item appears in the external source it is added to the widget on refresh (widgetPerformUpdateWithCompletionHandler).
The only thing that bugs me is that new items automatically slide in from the top, overlapping all previous items and finally reaching the final destination at the bottom of the list. How can I change this behavior to either slide in from the bottom or not at all and just appear without sliding. I think I know how I could do my own animation with ...view.animator()... but the original functionality is nowhere to be found in my code and I can't figure out how to disable it.
By now I'm pretty sure where it comes from. I assume the list items NSView is initiated with NSViewControllerTransitionOptions and the SlideDown option activated. So the animation comes from the views NSViewControllerPresentationAnimator. Unfortunately presentViewController is not called by myself. This probably is somewhere in the internals of NCWidgetListViewDelegate, which has no option to prevent or change the animation. So I guess, the only way how to "fix" this is to drop NCWidgetListViewDelegate completely and start from scratch. So the answer would be: It's not possible.

NSTableView redraw not updating display, selection sticking

Although I know of a solution to this problem, I am interested if someone can explain this solution to me. I also wanted to get this out there because I could not find any mention of this problem online, and it took me several hours over several days to track down. I have an NSTableView behaving strangely regarding redraws and its selection. The problem looks like this:
Table contents fades in, instead of appearing instantly upon it's appearance on screen. When scrolling through the contents, the newly appearing rows also fade in. When you make a selection (single or multiple), and scroll it off screen, then make another selection (that should replace, not add-to first selection), the first selection does not get cleared properly. If you scroll back to it, it is still there, in addition to your new selection. This is a display-update problem, not selection problem - i.e. your new selection is valid, it is just displayed wrong.
I tracked this through the NSArrayController I was binding to, the underlying Array, sorting, all the connections, and settings, etc., but all that has nothing to do with it.
What solved the problem was:
In the View Effects (right-most) Inspector, uncheck "Core Animation Layer" for the Window's main view.
Can anyone explain what is happening here, and perhaps improve upon the solution ?
It looks like Core Animation and NSTableView aren't getting along so well. The "fading" effect is a by-product of the way core animation works. When you have core animation in one view, it is also enabled in all of that view's subviews.
I don't recommend using core animation on the Mac unless absolutely necessary, because some interface elements (NSTextView and NSTableView, for example) aren't compatible with it. iOS has much better support for table views and such using core animation, mainly because it was designed with core animation in mind.
I know that some more simple UI elements are compatible (NSTextField and NSButton, for example).
If you absolutely need core animation in the rest of the window, put all the other views in a subview of the content view, while leaving the table view directly in the content view. You can then enable Core Animation in the other view.
Commenters, feel free to add to the list of what is and isn't compatible.

Resources