Post

Replies

Boosts

Views

Activity

Reply to How do I add local videos to my app in Swift UI?
What do you mean by local videos? Are they video files? If so, I do not understand what you think is difficult, it is as easy as adding images to your project. By the way, you are not finishing any of your previous posts. If any of the replies solved your issue, please mark the answer as SOLVED. If you solved your issue by yourself (including watching other sites), please post the answer by yourself and mark it SOLVED.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21
Reply to How do I add local videos to my app in Swift UI?
Hi, yes video files. I can't get them to play. I've tried using AVKit but idk if that's right So, your issue is playing the video added to the project, not adding the video to the project. First of all, please check the video files are added to the target: Select a video file in the Project navigator Find Target Membership in the File Inspector, and check there is a checked check mark on your app target. Assuming you have checked above and all OK, this is a simple video playing view: import SwiftUI import AVKit struct ContentView: View { let avPlayer = AVPlayer(url: Bundle.main.url(forResource: "video", withExtension: "mov")!) var body: some View { VideoPlayer(player: avPlayer) } } (Assuming video.mov is correctly added to the app target. Please do no forget that file system of iOS is case-sensitive.)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21
Reply to How do I add local videos to my app in Swift UI?
How do I mute the video in Swift UI, as this would sort my problem entirely? It's hard to say without seeing the view transition of your app. So just a simplified example: struct ContentView: View { let avPlayer = AVPlayer(url: Bundle.main.url(forResource: "video", withExtension: "mov")!) var body: some View { VideoPlayer(player: avPlayer) .onDisappear { avPlayer.isMuted = false } } } Where you can access avPlayer, you can call methods (or modify properties) of AVPlayer - https://developer.apple.com/documentation/avfoundation/avplayer in some action closure appropriate. If the view transitions of your app is more complex and you need to call AVPlayer methods from within more Views, you may need to consider how to share the same instance avPlayer among such Views.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21
Reply to Splitting text into cards
I did not receive an answer, and if I did, I could not understand and implement it. Unless you clarify what you want to do, your question will not be answered. https://stackoverflow.com/questions/66537950/how-can-i-split-text-into-cards Anyway, do everything for me-posts are not preferred both in stackoverflow and in the dev forums. Please clarify what you want to do and show what you have done till now.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21
Reply to isHidden
ios11 Edition Xcode 9 It seems it is an ancient old version, why don't you use the latest one? Those lines show no effect in the simulator: Why? Just showing some code fragments does not make sense. It may be called from somewhere it does not affect, or you might have something wrong in other places. Please show enough context, what you have done till now? What is the code of your current project?
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’21
Reply to Xcode Gives False '{' missing in class error
Your code is not properly formatted, so I cannot say if your code has some issue or not. Please try editing (or re-posting) your post with using Code block feature (icon ``). But Xcode often recalls old errors, so you may be seeing just an old error message. Have you tried Clean Build Folder or restarting your Xcode and Mac?
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’21
Reply to Why is this returning nil
Where would I put that? If you are showing the date just for debugging, you usually do not use DateFormatter and calculate the time difference between UTC and your region. I guess 17:30 UTC is 09:30 of your region, no? Then your code works as you expect. Only when you need to create a string representation for users, you need DateFormatter to convert Date to String. If you do want to use DateFormatter even for debugging output, you can write something like this: let calendar = Calendar(identifier: .gregorian) let components = calendar.dateComponents([.weekday], from: today) let nineThirtyToday = calendar.date( bySettingHour: 9, minute: 30, second: 0, of: today) let df = DateFormatter() df.timeZone = TimeZone.current df.dateStyle = .short df.timeStyle = .short print(df.string(from: nineThirtyToday ?? Date.distantPast)) (I recommend you to use the same calendar instance when getting components and nineThirtyToday to get consistent values.)
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’21
Reply to Pushed over tabs
 I am using tab navigation controller  I guess it is tab bar controller, if not, please tell us. What you have described is the usual behavior when you embed navigation controller inside any of the tab content. If you want to make what you wrote, you need to write some code to pop back the navigation controller. Typically, you make some class conform to UITabBarControllerDelegate and implement tabBarController(_:didSelect:).
Mar ’21