I'm creating a workout tracking app and in order to switch between view controller I use WKInterfaceController.reloadRootControllers(withNames:contexts:) to load a single controller that in awake(withContext:) hides/shows some elements and changes the text in some some labels. No problem here but sometimes the view is not loaded correctly and appears to be shifted a little bit to left and stretched vertically cropping some of the text: as you can see in the screenshots below the left part of the A and 5 is missing as well as the bottom of NEXT: ... and the green button is not centered:
I've tried delaying the updates to the view by invoking the code via DispatchQueue.main.async { ... } but that does nothing unfortunately and the only way to fix the problem is to terminate and relaunch the app but as this is not possible from the watch I have to uninstall it and reinstall it again, even reloading again the root controller does not help (the second screenshot is after said reload). Someone has an idea why this is happening?
Project on GitHub, the controller with this problem is ExecuteWorkoutInterfaceController in ExecuteWorkoutIC.swift.
You should check your storyboard layout and also maybe not use WKInterfaceController.reloadRootControllers and just have a method that hides and shows elements.
Related
I need to prevent scrolling to top on model update in angular 8 app.
I've tried saving scroll position and scrolling back to it after update, but this is visible to user and not good. I need a page to stay at the same place or getting back to it smoothly and quick.
I've also tried having the full model from the start to avoid updating it, but it is still needed in some cases.
You can use scrollIntoView:
#ViewChild("myElem") myElementToScroll: ElementRef;
this.myElementToScroll.nativeElement.scrollIntoView({block: 'start', behavior: 'smooth'});
You might want to check your routing. You might have a scroll to top in there. I am working in Angular 8, and my app doesn't scroll to the top on model update.
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.
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.
I have an NSSplitView inside an NSTabView. If the split view's tab is the one initially shown, it seems to work fine, but if the split view's tab is shown later instead, it appears with the first pane fully expanded and the second one collapsed. Because I want to use a thin divider for the split view, there is no way for the user to get out of this.
Returning NO from splitView:canCollapseSubview: doesn't help, even though I verified that it does get called.
As a workaround, I tried letting the split view's tab be initially shown, and then manually switching after the window is loaded (in awakeFromNib), but this did not fix it.
Is this a known issue with NSSplitView if it isn't initially shown? Is there a better way to apply the tab switching workaround? Or is there a better workaround?
I ended up getting around the issue by switching to RBSplitView. I also made a fork on GitHub to update the project to work with the latest 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 :)