1

UIButton同じものを表示する 4 を使用していますが、ボタンごとにUIPickerView異なる(4) が表示されます。NSArray4 を使用して、にロードするものとグラブするものを決定boolさせます。ボタン メソッドには 4 つのプロパティが含まれているだけで、3 つを に設定し、正しいもの (タップされたボタン) を に設定します。次に、が呼び出されて呼び出されます(両方で動作するように - で出力されます)。すべてのボタンは、 1 つを除いて (UIPickerView を何回持ってきたり閉じたりしても) 正常に動作しています(最初 - 中間 - 最後 - 任意の順序で押された場合でも)。Xcode は次の例外をスローします。UIPickerViewrow's textboolfalsetrueUIViewAnimateWithDurationUIPickerViewUIViewUIPickerViewUIToolbar

私がしたこと:

  • ボタンを削除し、新しいボタンを作成します
  • ボタンを作成するストーリーボード/コントローラーの両方の方法を試しました
  • を使用してボタンにメソッドを追加しましたaddtarget
  • ストーリーボードを使用した方法でリンクされたボタン

したがって、デバッガーのスローされた例外で表示できないものを誰かが表示できるかどうかを尋ねています:(sportCenter は aNSObjectであり、このコントローラーにはインポートされていません-それも試してみました!)

    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
4

1 に答える 1

2

オブジェクトに独自の copyWithZone: メソッドを追加する必要があります...

しかし、あなたの質問/文脈がよくわかりません。少し複雑な方法で設計されているように見えます。ブール配列は、悪いアプローチになる可能性があります。4 つのブール値を維持するよりも、コントローラーに selectedButton ( UIButton ) プロパティを設定して、どれが選択されているかを確認することをお勧めします。

最後に、状況に関係なく、最初のオブジェクトを除くすべてのオブジェクトで問題がなければ、多くの場合、どこかに配列インデックス エラーがあることを意味します。

お役に立てば幸いです。

于 2015-11-05T13:46:14.330 に答える