0
0
iOS Swiftmobile~10 mins

ScrollView 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 vertical ScrollView in SwiftUI.

iOS Swift
ScrollView([1]) {
    Text("Hello, ScrollView!")
}
Drag options to blanks, or click blank then click option'
A.both
B.none
C.vertical
D.horizontal
Attempts:
3 left
💡 Hint
Common Mistakes
Using .horizontal when vertical scrolling is needed.
Omitting the axis parameter causes a default vertical scroll.
2fill in blank
medium

Complete the code to add padding inside the ScrollView content.

iOS Swift
ScrollView(.vertical) {
    Text("Scrollable content")
        .[1](20)
}
Drag options to blanks, or click blank then click option'
Amargin
Bframe
Cborder
Dpadding
Attempts:
3 left
💡 Hint
Common Mistakes
Using margin which is not a SwiftUI modifier.
Using frame which changes size but not inner spacing.
3fill in blank
hard

Fix the error in the ScrollView code to make it compile.

iOS Swift
ScrollView(.vertical) {
    VStack {
        Text("Item 1")
        Text("Item 2")
    }[1]
}
Drag options to blanks, or click blank then click option'
A.padding()
B.background()
C.scrollable()
D.frame()
Attempts:
3 left
💡 Hint
Common Mistakes
Using .scrollable() which does not exist in SwiftUI.
Using .frame() without parameters may not fix the error.
4fill in blank
hard

Fill both blanks to create a horizontal ScrollView with spacing between items.

iOS Swift
ScrollView([1]) {
    HStack(spacing: [2]) {
        Text("A")
        Text("B")
        Text("C")
    }
}
Drag options to blanks, or click blank then click option'
A.horizontal
B10
C20
D.vertical
Attempts:
3 left
💡 Hint
Common Mistakes
Using .vertical axis with HStack causes no horizontal scroll.
Using spacing as a modifier instead of a parameter.
5fill in blank
hard

Fill all three blanks to create a ScrollView with a VStack that has padding and a background color.

iOS Swift
ScrollView(.vertical) {
    VStack {
        Text("Hello")
        Text("World")
    }[1]([2])
    .[3](Color.gray.opacity(0.2))
}
Drag options to blanks, or click blank then click option'
Apadding
B30
Cbackground
Dframe
Attempts:
3 left
💡 Hint
Common Mistakes
Using frame instead of padding for spacing.
Using background without parentheses.