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)
}
}
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
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.
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)
}
}
}
}
Hi! I am trying to make an App Clip that changes text based on a URL.
For example, I have a URL example.com/red?itemName=car.
I would like the App Clip's text to say "You have a red car"
How can I do this?
Hello,
When I try to install the iPadOS 17 public beta, my 32GB iPad says that it needs 13GB free to install the update! Is there a way to update to the beta without freeing up so much space? This is my main iPad so I don't want to reset it, but can I do it using Finder etc?
Bye!
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!