I am working on an app that allow user to taking notes, and I want to support inline editing that means users can use PencilKit feature and edit text in a single note just like the Notes app.
Is there any good idea to achieve this using SwiftUI?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
How to add a custom button to the Edit Menu on both iOS and iPadOS natively using SwiftUI.
I have seen many ways to implement custom button using UIKit but wondering how to use SwiftUI to achieve the same thing.
I have never seen any modifiers or Menus about this. I guest there is no way to do that.
Any idea about this? or is it a future update for SwiftUI ??
Is there any convenient way to back deploy the NavigationStack or NavigationSplitView??
The real problem is if I want to back support iOS 15 or 14, I must conditionally switch between NavigationView and NavigationStack / NavigationSplitView.
Here is how I did for NavigationStack, but I have no idea how to deal with NavigationSplitView
import SwiftUI
struct NavigationStack<Content: View>: View {
var content: () -> Content
var body: some View {
if #available(iOS 16.0, macOS 13.0, *) {
SwiftUI.NavigationStack {
content()
}
} else {
NavigationView {
content()
}.navigationViewStyle(.stack)
}
}
}
Will the new NavigationStack and NavigationSplitView back support old devices? I think these behaviors in previous OS is not new features.
How to add hosting base URL to a package(not a project)?
is it possible to add an existing Swift package to my project as a target?
If I set queueDepth to a value that smaller than 6 ( 5 for example ), the stream will be paused when I start capturing and make it minimized or hidden.
Is that a correct behavior or a bug??
Filed a report: FB11441320
If you configure a Window and a MenuBarExtra in your app, try this:
Open your app and press Command+H to hide it.
Place an iPad or another Mac and connect two devices via Universal Control, and click on the other device to make your mac's menu bar inactive.
Move your cursor back to your Mac(first device), and click on the whitespace of the Menu Bar.
Your App is terminated unexpectedly.
This behavior will only appear on those apps using Window, so to solve this issue, we may need to switch Window to WindowGroup which is not what we want.
I reappear this issue on Apple's ScreenCaptureKit Sample Code. This is a SwiftUI Scene BUG, please fix this.
@main
struct CaptureSampleApp: App {
var body: some Scene {
Window("ID", id: "ID") {
ContentView()
.frame(minWidth: 960, minHeight: 724)
.background(.black)
}
MenuBarExtra(
"App Menu Bar Extra", systemImage: "star"
) {
Text("Hello")
}
}
}
Filed a feedback: FB11447959.
I created a screen recording app.
Before appending the buffer to the writer, I check if the isReadyForMoreMediaData is true.
But sometimes it will constantly return false and won’t become true until I call markAsFinished
I have no idea how to fix this.
let videoCompressionProperties = [
AVVideoAverageBitRateKey: resolution.dataRate
]
let videoSettings: [String: Any] = [
AVVideoCodecKey: encoding,
AVVideoWidthKey: resolution.size.width,
AVVideoHeightKey: resolution.size.height,
AVVideoCompressionPropertiesKey: videoCompressionProperties,
AVVideoScalingModeKey: AVVideoScalingModeResizeAspect,
AVVideoColorPropertiesKey: colorSpace.properties.dictionary,
]
videoInput = AVAssetWriterInput(mediaType: .video, outputSettings: videoSettings)
videoInput?.expectsMediaDataInRealTime = true
Append buffers:
if videoInput?.isReadyForMoreMediaData == true {
guard buffer.imageBuffer != nil else { return }
processQueue.async { [self] in
videoInput?.append(buffer)
}
} else {
logger.warning("Dropped a frame.")
// I found this in stackoverflow. But no effect
// RunLoop.current.run(until: .now.addingTimeInterval(0.1))
// The code below will notify me when the bug occurrs.
// errorFixedPublisher.send()
// if !self.errorOccured {
// self.errorOccured = true
// let center = UNUserNotificationCenter.current()
// let content = UNMutableNotificationContent()
// content.sound = UNNotificationSound.defaultCritical
// content.badge = 1
// content.body = "Dropping frames at \(Date.now.formatted(date: .omitted, time: .standard))"
// let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false)
// let req = UNNotificationRequest(identifier: "ASWRI_ERR", content: content, trigger: trigger)
// center.add(req)
}
}
Any idea on it?? Please help me.
Have a good day!
Background
I use AVAssetWriterInput.append to append sample buffer to the writer. Sometimes, I switch off the audio input(if user wants to temporarily disable audio input), so the append method will not be executed while the append method in video input will always be executed.
Problem
If user pause the audio and resume it later. The audio after resuming will immediately begin when user pause it (in the final video).
Example
'=' refers to CMSampleBuffer.
'|' means user paused the audio input.
Video: ---------------=================================
Audio(expected): ----=======|----------------=============
Audio(I got): ---------=======|=============----------------
I have printed the presentationTime from the audio sample buffer, it turns out it's correct.
Maybe my understanding to the AVAssetWriterInput.append is wrong?
My current solution is to always append the buffer, but when user wants to pause, I simply append an empty SampleBuffer filled with nothing.
I don't think this is the best way to deal with it.
Is there any idea to sync the buffer time with the video??