这是一个相当简单的问题,但无法通过研究找到答案。
我知道在最初的 StoreKit API 中,您必须为用户提供恢复购买的能力。然而,对于 StoreKit2,WWDC 视频解释说,很少需要恢复购买(如果有的话),因为 StoreKit2 会自动侦听并保持交易最新。
那么,如果仅使用 StoreKit2 并且最低部署目标为 iOS 15,添加恢复购买按钮是否仍然是强制性的?
我有特定的代码行,仅当 ios 版本低于 15 时才执行。
我可以 if-else 如果 ios 很棒 15 这些。
if #available(iOS 15.0, *) {} else {}
Run Code Online (Sandbox Code Playgroud)
我想做相反的事情。如果ios版本低于15则执行特定的代码行。我知道我可以在其他部分编写代码,它应该可以工作,但正在寻找更多的想法和更快的应用程序方法
我有一个带有自定义颜色主题的应用程序,主题可以在TableView 标题标签和导航栏中实现颜色。
这样做时,它在 iOS14 上运行良好。但随着iOS15的变化,导航栏不能再改变颜色了。透明和scrollEdgeAppearance已在iOS15中处理,但应用程序运行时(调用application(didFinisLaunching)后)基于用户输入的导航栏当前颜色更改不起作用。
我使用以下代码在用户选择颜色时触发:
func setNavBarColour() {
if #available(iOS 15, *) {
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
appearance.backgroundColor = LangBuilds.flavColor
let proxy = UINavigationBar.appearance()
proxy.tintColor = LangBuilds.flavColor
proxy.standardAppearance = appearance
proxy.scrollEdgeAppearance = appearance
}
else {
self.navigationController?.navigationBar.barTintColor = LangBuilds.flavColor
}
self.searchController.searchBar.searchTextField.textColor = .black
self.searchController.searchBar.searchTextField.backgroundColor = .white
self.searchController.searchBar.searchTextField.autocapitalizationType = .none
changeTextHolder()
}
Run Code Online (Sandbox Code Playgroud)
提前感谢您的帮助。
不区分大小写的搜索 - swiftui iOS15
我希望用户搜索不区分大小写的数组。到目前为止,我通过小写数组项和搜索栏文本来实现这一点。我想知道是否有更简单的方法?
var searchResults: [Array] {
if searchText.isEmpty {
return filteredArray
} else {
return filteredArray.filter {
$0.name.lowercased().contains(searchText.lowercased())}
}
}
Run Code Online (Sandbox Code Playgroud) 对于单元测试,我将WKNavigationAction. 这是一种常见的做法,也可以在互联网和大型 SDK 中找到。
在 iOS 15 上,释放它的实例会导致 WebKit 内部崩溃。
堆栈跟踪:
Thread 1 Queue : com.apple.main-thread (serial)
#0 0x0000000130d8b702 in WTF::RunLoop::dispatch(WTF::Function<void ()>&&) ()
#1 0x0000000134ed41e4 in WebCoreObjCScheduleDeallocateOnMainRunLoop(objc_class*, objc_object*) ()
#2 0x000000011290711d in -[WKNavigationAction dealloc] ()
#3 0x000000010cf2f9f7 in objc_object::sidetable_release(bool, bool) ()
Run Code Online (Sandbox Code Playgroud)
游乐场示例:
import WebKit
class MockNavigationAction: WKNavigationAction {}
var navigationAction: WKNavigationAction? = MockNavigationAction()
navigationAction = nil
Run Code Online (Sandbox Code Playgroud)
非常感谢有关如何解决此问题的建议。
我已将 xcode 13 和 Visualstudio for mac 更新至版本 8.10.12。现在我有了 iPhone 13 模拟器和 iOS 15。问题是,当我尝试调试我的应用程序时,我从 Visual Studio 收到此错误。
\n\n\n错误 HE0046:无法在设备“iOS 15.0 (19A339) - iPhone 13 mini”上安装应用程序“ma.myapp.app”:\xe2\x80\x9cMyapp\xe2\x80\x9d 需要更新
\n
在 info.plist 中,最低版本设置为 iOS 9\n我不明白为什么我的应用程序可以在 iOS 14 上完美运行,但不能在 15 上运行。有人可以帮忙吗?
\n为什么我在 Xcode 12.4(模拟器 ios 14.x)中收到以下代码的构建错误?
if #available(iOS 15.0, *) {
myTableView.sectionHeaderTopPadding = 0.0 // error here
}
Run Code Online (Sandbox Code Playgroud)
错误是,
“UITableView”类型的值没有成员“sectionHeaderTopPadding”
如果 ios 15 不可用,Xcode 应该跳过编译此代码。不是吗?
// viewdidload register
[self.collectionView registerClass:[TestHeaderCollectionReusableView class]
forSupplementaryViewOfKind:UICollectionElementKindSectionHeader
withReuseIdentifier:NSStringFromClass(NEHeaderCollectionReusableView.class)];
// viewForSupplementaryElementOfKind called
TestHeaderCollectionReusableView *view = [collectionView dequeueReusableSupplementaryViewOfKind:kind
withReuseIdentifier:NSStringFromClass(TestHeaderCollectionReusableView.class)
forIndexPath:indexPath];
Run Code Online (Sandbox Code Playgroud)
在 iOS15 上,插入一个项目后
- (void)insertItem {
[self.dataSourece.firstObject insertObject:@{
@"title" : @"ins1"
} atIndex:0];
NSIndexPath * path= [NSIndexPath indexPathForItem:0 inSection:0];
[self.collectionView insertItemsAtIndexPaths:@[path]];
}
Run Code Online (Sandbox Code Playgroud)
在我插入项目后,它总是会在第一次重新创建 TestHeaderCollectionReusableView 。但在 iOS14 上,它将从缓存中进行杜克。
不知道为什么。
这是 SwiftUI 中的错误吗?如果你点击“测试”,它就会进入一个循环,永远一张一张地放。我不明白为什么。
iOS 和 iPadOS 15 上发生这种情况
struct ContentView: View {
@State private var showSheet = false
@State private var name: String = ""
@FocusState private var isFocused: Bool
var body: some View {
VStack {
Button("Test") { setState() }
}
.sheet(isPresented: $showSheet) {
VStack {
Text("\(showSheet.description), \(name)")
TextField("folder name", text: $name)
focused($isFocused)
}
}
}
private func setState() {
print("setState")
showSheet = true
}
}
Run Code Online (Sandbox Code Playgroud) 在 iOS15 上,在事件管理器中看不到应用程序事件。均位于“概述”和“测试事件”选项卡上。
我在 iOS 15 中遇到一个问题,将图像设置到右角时不起作用,而在 iOS 15 之前它可以正常工作。
我想要实现的目标:

这是我用于 iOS 15 的完整代码:
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let btnDropdown = getDropdownButton()
btnDropdown.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(btnDropdown)
NSLayoutConstraint.activate([
btnDropdown.heightAnchor.constraint(equalToConstant: 44),
btnDropdown.leadingAnchor.constraint(equalTo: view.layoutMarginsGuide.leadingAnchor),
btnDropdown.trailingAnchor.constraint(equalTo: view.layoutMarginsGuide.trailingAnchor),
btnDropdown.topAnchor.constraint(equalTo: view.layoutMarginsGuide.topAnchor, constant: 30)
])
}
fileprivate func getDropdownButton() -> UIButton {
var button: UIButton!
if #available(iOS 15.0, *),
let btnConfig = getButtonConfiguration() {
button = UIButton(configuration: btnConfig)
} else {
button = UIButton(type: .custom)
}
button.setTitle("Select Tags", for: .normal)
setupGeneralSettings(for: …Run Code Online (Sandbox Code Playgroud) 我试图在Picker所选选项旁边显示单词,但这些单词永远不会正确显示。我希望用户能够单击文本Picker也能够打开。我尝试将文本放在选择器之外,这会导致正确显示,但文本不可单击。我正在使用Xcode 13 Beta 5和iOS15。
struct ContentView: View {
@State var fruit = "Apple"
let fruits = ["Apple","Orange","Pear","Grape"]
var body: some View {
HStack {
Picker(selection: $fruit) {
Text("Picked:")
ForEach(fruits, id: \.self){ fruit in
Text(fruit)
}
} label: {
Text("")
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Run Code Online (Sandbox Code Playgroud)
为满足我的要求而进行的调整如下所示。现在,标签内的任何内容都可以单击。
Menu {
Picker(selection: $fruit, label: EmptyView()) {
ForEach(fruits, id: \.self) { fruit …Run Code Online (Sandbox Code Playgroud)