SwiftUI: Value of type ‘some View’ has no member ‘presentation’
Issue
Do you face this error Value of type 'some View' has no member 'presentation'
. Solution is quite simple..
Solution
You are working with an old version of the tutorial. The .presentation
modifier was from the SwiftUI beta days and was removed and replaced for each usage as follow:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.alert(isPresented: Binding<Bool>, ...) | |
.sheet(isPresented: Binding<Bool>, ...) | |
.popover(isPresented:Binding<Bool>, ...) |
Here is example for alert:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ContentView: View { | |
@State private var isDisplayed = false | |
var body: some View { | |
Button(action: { | |
self.isDisplayed = true | |
}) { | |
Text("Show Action Sheet") | |
} | |
.actionSheet(isPresented: $isDisplayed) { | |
ActionSheet(title: Text("What now?"), buttons: [.default(Text("Dismiss Action Sheet"))]) | |
} | |
} | |
} |
You should end up with something similar to this:
iOS Elements
You can find also the whole implementation in my UI kit — Download below.
Use discount code MOLCIK to get iOS Elements for $29.70 (70% off)