0
0
iOS Swiftmobile~10 mins

NavigationLink in iOS Swift - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a NavigationLink with a text label.

iOS Swift
NavigationLink(destination: Text("Detail View")) {
    Text([1])
}
Drag options to blanks, or click blank then click option'
Adestination
B"Go to Detail"
C"Button"
DDetailView()
Attempts:
3 left
💡 Hint
Common Mistakes
Using a view instead of a string inside Text.
Forgetting quotes around the string.
2fill in blank
medium

Complete the code to navigate to a custom view called DetailView.

iOS Swift
NavigationLink(destination: [1]) {
    Text("Show Detail")
}
Drag options to blanks, or click blank then click option'
A"DetailView"
BText("Detail")
CDetailView()
DNavigationView()
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a string instead of a view instance.
Passing a view type without parentheses.
3fill in blank
hard

Fix the error in the NavigationLink label to correctly display text.

iOS Swift
NavigationLink(destination: DetailView()) {
    [1]("Go")
}
Drag options to blanks, or click blank then click option'
ANavigationLink
BButton
CLabel
DText
Attempts:
3 left
💡 Hint
Common Mistakes
Using Button inside NavigationLink label causing nested buttons.
Using NavigationLink inside its own label.
4fill in blank
hard

Fill both blanks to create a NavigationLink with a label and destination view.

iOS Swift
NavigationLink(destination: [1]) {
    [2]("Next Screen")
}
Drag options to blanks, or click blank then click option'
ANextView()
BText
CDetailView()
DButton
Attempts:
3 left
💡 Hint
Common Mistakes
Using Button as label inside NavigationLink.
Passing a string instead of a view as destination.
5fill in blank
hard

Fill all three blanks to create a NavigationLink with a destination and a label showing an image and text.

iOS Swift
NavigationLink(destination: [1]) {
    HStack {
        Image(systemName: [2])
        Text([3])
    }
}
Drag options to blanks, or click blank then click option'
ASettingsView()
B"gearshape"
C"Settings"
DProfileView()
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around image systemName or text string.
Using wrong view as destination.