Why does SwiftUI code run/reloae on iPhone and not on iPad? - swiftui

I have been looking at this code and other similar code for the last week and have a question.
The app (code link below) is a simple 5 question app in SwiftUI. Using an iPhone 11 simulator, the quiz runs perfectly and when you hit the back nav link and press the Start Quiz button, the quiz runs again. On an iPad however the Start Quiz button does not work to relaunch the Quiz.
I figured since both are running the same IOS, they should both function the same but they do not. Tried it on my physical iPad and the same thing. Runs through the quiz once, and will not run a second time. Anybody have any idea why? Thanks for your help!
https://github.com/albypanz94/Quiz-Game-in-SwiftUI.git

The issue is that the SwiftUI Navigation model is, by default, based on a UISplitview, and that on the iPad, the "Start Quiz" navigation link transfers navigation to its second controller. On an iphone, the second controller is collapsed away.
What this means for the game is that for the iPad (and large iPhones in landscape mode), the game cannot re-start.
You would also find anomalies if you ran the game on a large format iPhone, and then rotated it mid way through the game.
You can change the navigation view style to not use the split view model by using:
.navigationViewStyle(StackNavigationViewStyle())
after the NavigationView closing brace.

Related

Is there anyway I can get the robot view out of Choregraphe? read body for more specifics

My main goal is to create a website that when you open it, it shows the identical view that the Robot view has in Choregraphe (virtual robot and everything) and then you could send a behavior to the robot on that website and the robot would do the behavior. But I am trying to figure out if I can just get the robot view by itself. Like imagine opening Choregraphe but it opens with just the robot view (a view of the robot). Let me know if anyone has dealt with this, thanks.
No, the robot view is handled by a native program showing the view on your PC screen. Apart by capturing the screen, it is not designed to be redirected to a web page.
However NAO and Pepper robots are compatible with ROS, and you can setup web views showing any robot running ROS. I found this online course that could teach you exactly how to do that.

swiftui button show in preview, but never show in simulator or device

please see the below image, I just have one button in swiftui content view.
you can see this button show in preview fine, but never show in similuator, or device. just blank there.
any idea what it is ?
I think it's your simulator or device can not support [Color("DarkGreen"), Color("LightGreen")], if you change [Color("DarkGreen"), Color("LightGreen")] to [Color.red, Color.green], you will see it.

Prevent SwiftUI App from going to sleep op WatchOS

I'm trying to record some CoreMotion data from a watch app I'm making. Every time I go to move, however, the app goes inactive after a while. Since this app is more for testing purposes, I'd like to keep it active as long as it's recording data.
I think I'm basically looking for the SwiftUI equivalent on WatchOS of UIApplication.shared.isIdleTimerDisabled = true.

how can i change focus from one object to next preferred focus view which i want in appleTv os development project in swift3

Actually i'm developing a Apple Tv project in swift3.I faced some problem with focus navigation using remote.
Is there any way to change focus from one object to another object which i want.
I tried below code but not working......
override var preferredFocusedView: UIView? {
get {
return preferredFocusedView1
}
}
In the bellow screenshot i want to move focus from the pink icon to the star button when pressed down button of remote. how it is possible. plz provide me some code in details

how to reset game in cocos2d

My question in the previous post was-
I have a cocos2d game, and after I
exit the game and start it again, it
starts at the exact same point it was
before closing.why this is
happening??and not only this, my game
is landscapemode but when I start it
again from simulator it comes in
portrait mode,not it landscapemode like
first time.
Is there any way to prevent this?
Anyone will come to rescue me???
I found a solution.Is it good??
when I exit the game(by pressing the back button in iPhone simulator) this problem occurred. Now I found that if I press back button the following function is called-
(void)applicationWillResignActive:(UIApplication *)application
So I set (divide by zero) or something like this in -(void)applicationWillResignActive function so that when this function called the application crashes. Then if I restart the application everything comes from beginning(reset) which I want. Is it good solution or anything better?
*my applicationDidFinishLaunching was not called again when application is restart from simulator.
You should configure the Info.plist to indicate that you does not want your application run in Background.
The key is
UIApplicationExitsOnSuspend
If you need more detail you should look at this tutorial
If you have iOS 4.0 or higher, multitasking is causing your problem.