我使用以下代码来检测用户更改的系统音量。
NotificationCenter.default.addObserver(self, selector: #selector(volumeChanged), name: NSNotification.Name(rawValue: "AVSystemController_SystemVolumeDidChangeNotification"), object: nil)
Run Code Online (Sandbox Code Playgroud)
当我更新到 iOS 15 时,我发现这段代码不起作用,但对于任何以前版本的 iOS 来说它都有效。
我也使用了一个addObserver函数,但没关系。
这是 iOS 15 的错误吗?如果是,我该如何修复它。
谢谢 :)
由于某种原因,我无法在 iPadOS 15(测试版 5)中使用硬件键盘快捷键。它们适用于大多数键,但不适用于箭头键和 Tab 键。
当在 Xcode 13(beta 4)中编译并在 iPadOS 14.5 模拟器上运行时,相同的代码似乎运行良好,但在使用相同的 Xcode 但在 iPadOS 15 sim 上构建时拒绝工作。我已经在运行 iPadOS 15 beta 5 的实际设备上进行了尝试,结果相同。
这是一个最小的例子:
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
addKeyCommand(UIKeyCommand(title: "UP", action: #selector(handle(key:)), input: UIKeyCommand.inputUpArrow, modifierFlags: []))
addKeyCommand(UIKeyCommand(title: "DOWN", action: #selector(handle(key:)), input: UIKeyCommand.inputDownArrow, modifierFlags: []))
addKeyCommand(UIKeyCommand(title: "TAB", action: #selector(handle(key:)), input: "\t", modifierFlags: []))
}
@objc func handle(key: UIKeyCommand?) {
NSLog("Intercepted key: \(key?.title ?? "Unknown")")
}
}
Run Code Online (Sandbox Code Playgroud)
我还没有找到任何相关报告或开放雷达,所以我怀疑我可能在这里遗漏了一些东西。如果应该报告此问题,我应该在哪里报告此类错误?
谢谢。
尝试使用 iOS 15 的新 Canvas/TimelineView。我尝试使用官方 WWDC 教程创建粒子系统,但无法修复与性能相关的问题。
这是代码:
struct MyView: View {
@State private var count = 32*32
var body: some View {
TimelineView(.animation) { timeline in
Canvas { context, size in
let now = timeline.date.timeIntervalSinceReferenceDate
for i in 0..<count {
context.fill(Ellipse().path(in: CGRect(x: size.width*0.01*Double(i), y: size.height*0.01*Double(i), width: 20.0, height: 20.0)), with: .color(.green))
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
它只绘制了 1024 个圆圈,但已经消耗了模拟器 CPU 的 20% 和 iPhone 8 CPU 的 50%。考虑到 iPhone 的强大功能以及新框架的有效性,这是预期的行为吗?如果我需要超过 1024 个圆圈,我应该如何解决这个问题?
这在 iOS 15 之前运行良好
let center = UNUserNotificationCenter.current()
let content = UNMutableNotificationContent()
content.sound = UNNotificationSound.init(named:UNNotificationSoundName(rawValue: sound))
let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger)
center.add(request)
Run Code Online (Sandbox Code Playgroud)
用户收到通知声音,iOS 15 之后我必须添加
content.body = "Hello iOS 15"
Run Code Online (Sandbox Code Playgroud)
无论如何,只能在 iOS 15 上发送带有声音的本地通知?
随着新的 XCode 13 和它\xe2\x80\x98s iOS 15 支持,列表的呈现方式明显发生了变化。\n现在列表有一个额外的灰色背景。之前,背景是纯白色的,正如我所希望的那样。当我添加文本等其他元素时,默认背景颜色仍然是白色。
\n有没有办法摆脱列表的灰色周围而不切换到ForEach()解决方案?
我尝试在各个地方将背景颜色从灰色更改为白色,并添加额外的堆栈以希望覆盖默认背景颜色。
\n我希望它是全白色的,没有灰色周围:
\n\nstruct ContentView: View {\n var body: some View {\n \n VStack {\n Text("Test")\n \n List {\n ForEach(1..<20) { i in\n Text(String(i))\n } \n }.frame(maxWidth: .infinity) \n } \n \n }\n}\nRun Code Online (Sandbox Code Playgroud)\n 在 iOS 15 上,当导航到具有透明导航栏的视图控制器时,透明栏的动画无法按预期工作。
但是,如果您导航回带有透明导航栏的视图控制器,动画将按预期工作。
这就是我设置视图控制器的方式:
根VC
let appearance = UINavigationBarAppearance()
appearance.configureWithDefaultBackground()
appearance.backgroundColor = UIColor.red
self.navigationController?.navigationBar.standardAppearance = appearance
self.navigationController?.navigationBar.scrollEdgeAppearance = self.navigationController?.navigationBar.standardAppearance
Run Code Online (Sandbox Code Playgroud)
第一VC
let appearance = UINavigationBarAppearance()
appearance.configureWithTransparentBackground()
self.navigationController?.navigationBar.standardAppearance = appearance
self.navigationController?.navigationBar.scrollEdgeAppearance = self.navigationController?.navigationBar.standardAppearance
Run Code Online (Sandbox Code Playgroud)
第二VC
let appearance = UINavigationBarAppearance()
appearance.configureWithDefaultBackground()
appearance.backgroundColor = UIColor.yellow
self.navigationController?.navigationBar.standardAppearance = appearance
self.navigationController?.navigationBar.scrollEdgeAppearance = self.navigationController?.navigationBar.standardAppearance
Run Code Online (Sandbox Code Playgroud)
请注意以下示例中从secondaryVC -> firstVC的过渡是多么平滑,但不是从rootVC -> firstVC的过渡:
示例项目: https: //github.com/karlingen/NavigationTest
有什么想法为什么会这样吗?
uinavigationbar uinavigationcontroller ios uinavigationbarappearance ios15
我有以下代码:
struct Credential: Equatable {
var username = ""
var password = ""
}
enum Database {
static var credential = Credential()
}
struct UsernamePasswordInput: View {
@Binding var credential: Credential
var body: some View {
Group {
TextField("Username", text: self.$credential.username)
SecureField("password", text: self.$credential.password)
}
.textFieldStyle(RoundedBorderTextFieldStyle())
}
}
struct Login: View {
private var credential: Binding<Credential>
var body: some View {
UsernamePasswordInput(credential: self.credential)
}
init() {
self.credential = Binding<Credential>(
get: {
Database.credential
}, set: { newValue in
Database.credential = newValue …Run Code Online (Sandbox Code Playgroud) 我想禁用当我们长按任何 html 元素时出现的文本放大镜。
在IOS15中又开始出现了。
我尝试了以下方法,但在iOS15上不起作用。 在 iOS html 应用程序中禁用放大镜
您知道任何 CSS 属性或其他禁用它的方法吗?
上面的文章是论坛上一位网友发现的问题。最近,我也在firebase上发现了类似的崩溃堆栈。我猜也是这个原因造成的,可能是数据越界的问题。你有好的解决办法吗?
Firebase 使堆栈崩溃:
Fatal Exception: NSInternalInconsistencyException
Invalid parameter not satisfying: pos
0
CoreFoundation
__exceptionPreprocess
1
libobjc.A.dylib
objc_exception_throw
2
Foundation
_userInfoForFileAndLine
3
UIKitCore
-[_UITextKitTextPosition compare:]
4
UIKitCore
-[UITextInputController comparePosition:toPosition:]
5
UIKitCore
-[UITextView comparePosition:toPosition:]
6
UIKitCore
-[UITextPasteController _clampRange:]
7
UIKitCore
__87-[UITextPasteController _performPasteOfAttributedString:toRange:forSession:completion:]_block_invoke
8
UIKitCore
__87-[UITextPasteController _performPasteOfAttributedString:toRange:forSession:completion:]_block_invoke.177
9
UIKitCore
-[UITextInputController _pasteAttributedString:toRange:completion:]
10
UIKitCore
-[UITextPasteController _performPasteOfAttributedString:toRange:forSession:completion:]
11
UIKitCore
__49-[UITextPasteController _executePasteForSession:]_block_invoke
12
libdispatch.dylib
_dispatch_call_block_and_release
13
libdispatch.dylib
_dispatch_client_callout
14
libdispatch.dylib
_dispatch_main_queue_callback_4CF
15
CoreFoundation
__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
16
CoreFoundation
__CFRunLoopRun
17
CoreFoundation
CFRunLoopRunSpecific
18
GraphicsServices
GSEventRunModal
19
UIKitCore …Run Code Online (Sandbox Code Playgroud) video包含属性设置为包含视频文件的数据 URI 的元素的网页src不会在 iOS 15 上的 Safari 中播放视频。
使用 Safari 开发工具检查设备/模拟器表明浏览器重复发出带有Range: bytes N-M标头的请求,多次读取整个视频文件,导致巨大的内存消耗并最终无法开始播放。
如果视频足够小并且确实能够启动,则播放速度会显得很慢,甚至需要很长时间才能启动。
有解决这个问题的方法吗?
PS 将视频保留在 Data URI 中是我试图解决的任务所固有的,因此请不要建议将视频文件保留为单独的资源:)
ios15 ×10
ios ×5
swiftui ×3
swift ×2
css ×1
html ×1
html5-video ×1
ipados ×1
ipados15 ×1
javascript ×1
safari ×1
swiftui-list ×1
uikeycommand ×1
uitextview ×1
volume ×1
webkit ×1
xcode ×1