Post not yet marked as solved
NavigationLink in List is automatically designed.
How to set appropriate multi NavigationLink in Cell?
I don't want use ForEach in ScrollView. Because I want to use swipeActions.
struct TimelineView: View {
let tweets: [Tweet] = tweets
let users: [User] = users
var body: some View {
NavigationStack {
List(tweets) { tweet in
let user = users.first { $0.id == tweet.userID }!
NavigationLink(value: tweet) {
HStack {
NavigationLink(value: user) {
Image(systemName: "person")
.foregroundStyle(user.color)
}
VStack {
Text("@\(user.name)")
Text(tweet.text)
}
}
}
.swipeActions(edge: .leading) {
Button("Like") { }
}
}
.navigationDestination(for: Tweet.self) { tweet in
TweetDetailView(tweet: tweet)
}
.navigationDestination(for: User.self) { user in
UserDetailView(user: user)
}
}
}
}
Post not yet marked as solved
struct ContentView: View {
@State var isPresented = false
var body: some View {
Button {
isPresented.toggle()
} label: {
Text("Button")
}
.sheet(isPresented: $isPresented) {
SubView()
}
}
}
struct SubView: View {
@State var text = ""
var body: some View {
NavigationStack {
TextEditor(text: $text)
.toolbar {
ToolbarItemGroup(placement: .bottomBar) {
Button("Click") {
}
}
ToolbarItemGroup(placement: .keyboard) {
Button("Click") {
}
}
}
}
}
}
Post not yet marked as solved
Pick 2 Photo with PhotosPicker
Deselect 2 Photo in PhotosPicker And Done
selection(PhotosPickerItem) doesn't change
PhotosPicker(selection: $photoPickerItems,
maxSelectionCount: 0,
selectionBehavior: .ordered,
matching: nil,
preferredItemEncoding: .current,
photoLibrary: .shared()) {
Image(systemName: "photo")
}
Post not yet marked as solved
I use loadFileRepresentation(forTypeIdentifier:completionHandler:) to load video with PHPickerViewController
What can I use load video with?
// my sample code
func loadPhoto(pickerItem: PhotosPickerItem) async throws -> Photo {
if let livePhoto = try await pickerItem.loadTransferable(type: PHLivePhoto.self) {
let photo: Photo = .init(id: pickerItem.itemIdentifier, item: livePhoto)
return photo
} else if let url = try await pickerItem.loadTransferable(type: URL.self) {
let photo: Photo = .init(id: pickerItem.itemIdentifier, item: url)
return photo
} else if let data = try await pickerItem.loadTransferable(type: Data.self) {
let photo: Photo = .init(id: pickerItem.itemIdentifier, item: data)
return photo
}
throw PhotoError.load
}
Post not yet marked as solved
NavigationLink(destination:isActive:label:) is deprecated in iOS 16
How to implement below View in iOS 16 without Deprecated?
struct ContentView: View {
@State var isPresentedDetailView = false
@State var isPresentedImageView = false
var body: some View {
NavigationStack {
List {
HStack {
Button("Name") { isPresentedDetailView.toggle() }
NavigationLink(isActive: $isPresentedDetailView) {
Text("Detail View")
} label: {
EmptyView()
}
.frame(width: 0, height: 0)
.hidden()
Image(systemName: "person")
.onTapGesture {
isPresentedImageView.toggle()
}
NavigationLink(isActive: $isPresentedImageView) {
Image(systemName: "person")
} label: {
EmptyView()
}
.frame(width: 0, height: 0)
.hidden()
}
}
}
}
}