小编Jer*_*sey的帖子

存储的属性不能用“@available”标记为可能不可用

我在 Swift 中发现了一个关于 @available 的有趣问题。我在我封装的TableView中添加了一个支持iOS 11及以上版本的var“UISwipeActionsConfiguration”,以支持列表单元格的左滑编辑和删除功能。我尝试模仿UITableView的写法来装饰Var,但是IDE直接编译报错。我只能尝试另一个set get方法来装饰。我不禁怀疑苹果开源的Swift源代码是如何隐藏的。已编译。

以下是苹果示例代码:

@available(iOS 2.0, *)
open class UITableView : UIScrollView, NSCoding, UIDataSourceTranslating {
    @available(iOS 10.0, *)
    weak open var prefetchDataSource: UITableViewDataSourcePrefetching?

    @available(iOS 11.0, *)
    weak open var dragDelegate: UITableViewDragDelegate?

    @available(iOS 11.0, *)
    weak open var dropDelegate: UITableViewDropDelegate?
}
Run Code Online (Sandbox Code Playgroud)

下面是我的示例代码:

@available(iOS 11.0, *)
public protocol HTCTableViewDelegate {
    func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration?
}
@available(iOS 11.0, *)
public typealias EditSwipeActionsCellCallback = (_ viewModel: Any, _ sectionModel: HTCTableViewSection) -> UISwipeActionsConfiguration? 

public class JSDTableView …
Run Code Online (Sandbox Code Playgroud)

iphone xcode ios swift

13
推荐指数
1
解决办法
2万
查看次数

iOS15 UITextView 拖动视图后导致崩溃,Invalid参数不满足:pos

崩溃示例

上面的文章是论坛上一位网友发现的问题。最近,我也在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)

uitextview uitextviewdelegate ios ios15

6
推荐指数
1
解决办法
1953
查看次数

标签 统计

ios ×2

ios15 ×1

iphone ×1

swift ×1

uitextview ×1

uitextviewdelegate ×1

xcode ×1