0
0
iOS Swiftmobile~5 mins

List view basics in iOS Swift - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a List in SwiftUI?
A List in SwiftUI is a view that displays rows of data in a single column, similar to a table. It is used to show collections of items in a scrollable list.
Click to reveal answer
beginner
How do you create a simple list of static text items in SwiftUI?
You use List with static views inside, like:<br>List { Text("Item 1") Text("Item 2") }
Click to reveal answer
intermediate
What is the purpose of the ForEach inside a List?
ForEach lets you create a list from a dynamic collection of data by repeating views for each item.
Click to reveal answer
intermediate
Why do items in a List need to be Identifiable?
SwiftUI needs to know how to uniquely identify each item to manage updates and animations efficiently. Making items Identifiable provides a unique ID for each.
Click to reveal answer
beginner
How can you add a navigation title to a List in SwiftUI?
Wrap the List in a NavigationView and use .navigationTitle("Title") modifier on the List or its container.
Click to reveal answer
Which SwiftUI view is used to display a scrollable list of rows?
AVStack
BList
CHStack
DZStack
What does ForEach do inside a List?
AAdds a button to the list
BCreates a single static row
CRepeats views for each item in a collection
DChanges the list background color
Why must items in a List be Identifiable?
ATo allow SwiftUI to track each item uniquely
BTo change font size
CTo display images
DTo add animations manually
How do you add a title to a List screen?
AUse .title() modifier on List
BUse .font() modifier on List
CAdd Text above List
DWrap List in NavigationView and use .navigationTitle()
Which of these is NOT a correct way to create a List?
AList { VStack { Text("One") Text("Two") } }
BList(items) { item in Text(item) }
CList { Text("One") Text("Two") }
DList { ForEach(items) { item in Text(item) } }
Explain how to create a dynamic list of items in SwiftUI and why Identifiable is important.
Think about how SwiftUI knows which row is which when data changes.
You got /5 concepts.
    Describe how to add a navigation title to a list screen in SwiftUI.
    Remember the container that enables navigation features.
    You got /4 concepts.