- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 4 个 UIButton
调出相同的 UIPickerView
但每个按钮显示不同的 NSArray
(4)。使用 4 bool
让 UIPickerView
决定加载哪个,以及抓取哪个 row's text
。按钮方法仅包括四个 bool
属性,将三个属性设置为 false
并将正确的一个(点击的按钮)设置为 true
。然后调用 UIViewAnimateWithDuration
调出 UIPickerView
(在 UIView
中打印 - 对于 UIPickerView
和 UIToolbar
一起工作)。除了 one 之外,所有按钮都工作正常(无论我打开/关闭 UIPickerView 多少次)(即使按第一个 - 中间 - 最后一个顺序按下)。 Xcode 抛出以下异常:
我做了什么:
addtarget
向按钮添加方法所以我要问的是,是否有人能看到我在调试器抛出的异常中看不到的任何东西:(sportCenter 是一个 NSObject
并且它没有导入到这个 Controller 中 - 也试过了!)
2015-11-05 13:14:36.356 -----[3975:1397857] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[sportCenter copyWithZone:]: unrecognized selector sent to instance 0x7f8709f62250'
*** First throw call stack:
(
0 CoreFoundation 0x0000000103673f45 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001030eddeb objc_exception_throw + 48
2 CoreFoundation 0x000000010367c56d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x00000001035c9eea ___forwarding___ + 970
4 CoreFoundation 0x00000001035c9a98 _CF_forwarding_prep_0 + 120
5 UIKit 0x0000000103c8954b -[UILabel _setText:] + 114
6 UIKit 0x0000000103a0580c -[UIPickerView tableView:cellForRowAtIndexPath:] + 863
7 UIKit 0x000000010429c146 -[UIPickerColumnView tableView:cellForRowAtIndexPath:] + 103
8 UIKit 0x0000000103b75e2a -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 782
9 UIKit 0x0000000103b75f3f -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 74
10 UIKit 0x0000000103b4b307 -[UITableView _updateVisibleCellsNow:isRecursive:] + 3187
11 UIKit 0x0000000103b5d369 -[UITableView cellForRowAtIndexPath:] + 186
12 UIKit 0x000000010412419a -[UIPickerTableView selectRow:animated:notify:] + 342
13 UIKit 0x0000000103a0421f -[UIPickerView _resetSelectionOfTables] + 157
14 UIKit 0x0000000103a040ab __30-[UIPickerView layoutSubviews]_block_invoke + 9523
15 UIKit 0x0000000103ac9c10 +[UIView(Animation) performWithoutAnimation:] + 65
16 UIKit 0x0000000103a01b33 -[UIPickerView layoutSubviews] + 147
17 UIKit 0x0000000103a04fcb -[UIPickerView selectedRowInComponent:] + 45
18 UIKit 0x0000000103a0009e -[UIPickerView _updateSelectedRows] + 135
19 UIKit 0x0000000103a001cf -[UIPickerView didMoveToWindow] + 117
20 UIKit 0x0000000103acebe0 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1768
21 UIKit 0x0000000103ace856 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 862
22 UIKit 0x0000000103ac3e2c __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 155
23 Foundation 0x0000000102cc3d4a -[NSISEngine withBehaviors:performModifications:] + 155
24 UIKit 0x0000000103ac3d4a -[UIView(Hierarchy) _postMovedFromSuperview:] + 575
25 UIKit 0x0000000103ad17e7 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1967
26 --- 0x00000001026cbe7b -[AllOngoingViewController animatePickerView] + 107
27 --- 0x00000001026cbcd7 -[AllOngoingViewController centersAreTapped] + 71
28 UIKit 0x0000000103f0194f _UIGestureRecognizerSendTargetActions + 153
29 UIKit 0x0000000103efdfc1 _UIGestureRecognizerSendActions + 162
30 UIKit 0x0000000103efbfbe -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 843
31 UIKit 0x0000000103f04283 ___UIGestureRecognizerUpdate_block_invoke898 + 79
32 UIKit 0x0000000103f04121 _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 342
33 UIKit 0x0000000103ef1bdd _UIGestureRecognizerUpdate + 2634
34 UIKit 0x0000000103a8f9c0 -[UIWindow _sendGesturesForEvent:] + 1137
35 UIKit 0x0000000103a90bf6 -[UIWindow sendEvent:] + 849
36 UIKit 0x0000000103a402fa -[UIApplication sendEvent:] + 263
37 UIKit 0x0000000103a1aabf _UIApplicationHandleEventQueue + 6844
38 CoreFoundation 0x00000001035a0011 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
39 CoreFoundation 0x0000000103595f3c __CFRunLoopDoSources0 + 556
40 CoreFoundation 0x00000001035953f3 __CFRunLoopRun + 867
41 CoreFoundation 0x0000000103594e08 CFRunLoopRunSpecific + 488
42 GraphicsServices 0x0000000106616ad2 GSEventRunModal + 161
43 UIKit 0x0000000103a2030d UIApplicationMain + 171
44 ----- 0x00000001026c1caf main + 111
45 libdyld.dylib 0x000000010a19e92d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
最佳答案
您必须在对象中添加自己的 copyWithZone: 方法...
但是,我不太了解您的问题/上下文。它看起来设计得有点复杂。 bool 数组有可能是一种糟糕的方法。最好在 Controller 中有一个 selectedButton ( UIButton ) 属性,以了解选择了哪个,而不是维护四个 bool 值。
最后,无论情况如何,如果除第一个对象之外的所有对象都正常工作,则通常意味着某处存在数组索引错误。
希望对你有帮助。
关于ios - 当前类中不包含对象的 copywithzone 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33545721/
这是场景,我有这个 Person 对象数组。 copyWithZone 在 Person 上实现并按预期工作。 我有一个 Person 对象数组,但是当我创建该数组的副本并修改原始数组中的内容(更改
我正在尝试通过执行以下操作来制作 UIViewController 子类的副本: BookViewController *bookVC = [catalogFlatViewController cop
我正在使用以下代码来实例化 View SenderPlayerViewController 并传递对象“session”: - (void)session:(GKSession *)session p
我正在使用 4 个 UIButton 调出相同的 UIPickerView 但每个按钮显示不同的 NSArray(4)。使用 4 bool 让 UIPickerView 决定加载哪个,以及抓取哪个 r
我正在使用 Mogenerator 来生成我的模型。所以在我的人类模型中我有 - (id)copyWithZone:(NSZone *)zone { AppointmentGrid *appo
所以我有 2 个对象。 Library.h: NSString *name; Book *book; Book.h: NSString *title NSString *aut
我有一个表示结构的类。 这个名为 Object 的类具有以下属性 @property (nonatomic, strong) NSArray *children; @property (nonatom
我正在使用以下代码来实例化 View SenderPlayerViewController 并传递对象“session”: - (void)session:(GKSession *)session p
copyWithZone(见下文)是否正确,尤其是我使用 setter 填充新对象实例变量的那一点? @interface Planet : NSObject { NSString *nam
我正在努力澄清一些关于实现 copyWithZone: 的事情,任何人都可以评论以下内容... // 001: Crime is a subclass of NSObject. - (id)copyW
我有一个封装 ABRecordID 的类,当它用作添加到 NSMutableDictionary 的键时,我收到运行时异常: "NSInvalidArgumentException: *** -[My
我正在阅读 Chung 的“Pro. Objective-C Design Patterns for iOS”并发现 _sharedSinglton = [[super allocWithZone:
This question already has answers here: Closed 7 years ago. Possible Duplicate: Arrow operator (->)
我们试图在 xcode 中的两个 View 之间传递信息。我们以一种形式获取一些信息,我们将在下一个 View 中显示这些信息。我们发送了信息,但我们无法在第二个 View 中接收到它并用我们发送的信
我正在尝试使用 KVO 更新我的自定义 tableviewcell (DHtableViewCell) 中的值。我不断收到此错误。我知道还有其他人也有同样的异常(exception),但他们的解决方案
我有一个自定义类 Thing:NSManagedObject,其属性为 adminName。 我试图在这个 Thing 类中创建一个 copyWithZone 函数,但是当我运行该应用程序时,它说 s
Xcode 4 静态分析器将此方法标记为具有过度释放的返回值,而实际情况似乎并非如此。 - (id)copyWithZone:(NSZone *)zone { return [[[self c
我读了其他一些关于它的主题,但我仍然迷路了。 我想创建两种对象,一种是只有“只读”属性的不可变对象(immutable对象),另一种是只有“读写”属性的可变对象。 我们称它们为 EXCar 和 EXM
在类中实现 NSCopying 的此方法以启用复制时,区域参数使用什么?如果我设置一个新对象,我不需要用 allocWithZone 来分配它,因为 alloc 就足够了......我很困惑.....
假设我有一堂这样的课: @interface SomeClass : NSObject { SomeOtherClass *obj; } 在 copyWithZone: 的定义中,我这样做:
我是一名优秀的程序员,十分优秀!