Post

Replies

Boosts

Views

Created

Redirect to view after button clicked
Hi! I am making an app where you connect to the device and then it takes you to a Device Home view. I have gotten the connection to work, but how can I redirect to the Device Home view? Here is the SwiftUI code for the button: swift Button(action: { let clientID = "Momo-iOS-"+String(Int.random(in: 0..100)) let mqtt = CocoaMQTT(clientID: clientID, host: "192.168.1.26") mqtt.connect() }) { ZStack { RoundedRectangle(cornerRadius: 100).fill(Color.yellow).frame(width: 240, height: 80)   Text("Connect").font(.system(size: 26)).foregroundColor(.white)   } }
0
0
828
Feb ’21
Multi-View App
Hi. I am trying to make an app to control a robot. The app will be entirely SwiftUI and will have a structure like this: Connect button View-Home Screen ---Games Mode ---Drive Mode ---Code Lab How will I make the navigation? I have made the views already but don't know how to use navigation in SwiftUI.
0
0
816
Feb ’21
SwiftUI Background Color not Working
Hi. I am making an app with a background image, but that does not take up the full screen on Pro Max iPhones, so I am setting a background color behind the image. Surprisingly, the background color is not showing up. Here is the code of the View: struct IntroView: View {     @StateObject var viewRouter: ViewRouter     var body: some View {         ZStack {             Color("AccentColor").edgesIgnoringSafeArea(.all)             Image("GameStart")             VStack {                 Text(""" The NS Labs app is a placeholder to not show confidential app name """                 ).font(.system(size: 20)).frame(width: UIScreen.screenWidth, height: 250).foregroundColor(Color(.systemBlue)) Text(""" Welcome to the NS Labs App """ ).font(.system(size: 20)).frame(width: UIScreen.screenWidth, height: 200).foregroundColor(Color(.systemBlue))                 Text("Click Let’s Go to start using the NS Labs app!").font(.system(size: 20)).frame(width: UIScreen.screenWidth, height: 200).foregroundColor(Color(.systemYellow)).padding(.bottom, 20)                 Button(action: {                     viewRouter.currentPage = .page2                 }) {                     Text("Let's Go!").foregroundColor(.white).font(.system(size: 34)) }.frame(width: 200, height: 70).background(Color.yellow).cornerRadius(12)             }         } } }
1
0
1.6k
Oct ’21
Entity not returning to original position
Hello, I am making a RealityKit app where a ball goes and hits some stones, and then goes back to its original position. However, in moving back the ball always tilts a little and sometimes even goes backwards or in other directions! I add my entities in these lines of code: stoneEntity!.scale = [5, 5, 5] anchor.addChild(stoneEntity!) stoneEntity!.transform.translation = SIMD3<Float>(anchor.position.x, anchor.position.y, anchor.position.z) stoneX = stoneEntity!.position.x stoneY = stoneEntity!.position.y stoneZ = stoneEntity!.position.z stoneEntity?.generateCollisionShapes(recursive: true) // Add ball entity anchor.addChild(ballEntity) ballEntity.transform.translation = SIMD3<Float>(anchor.position.x, anchor.position.y, anchor.position.z + 1) ballEntity.generateCollisionShapes(recursive: true) ballEntity.physicsBody = PhysicsBodyComponent(massProperties: PhysicsMassProperties.default, material: PhysicsMaterialResource.default, mode: .kinematic) ballEntity.collision = CollisionComponent(shapes: [.generateSphere(radius: 0.1)], mode: .default, filter: .default) ballEntity.physicsBody?.isTranslationLocked = (true, true, false) view.scene.addAnchor(anchor) And move my ball back in the code: ballEntity.transform.translation = SIMD3<Float>(0, 0, 1) If anyone has any ideas please could you let me know ASAP? Thank you!
1
0
846
Feb ’24