如何将当前检查的字符串分配给detailLabel UITableViewCell?

时间:2015-09-01 09:43:57

标签: ios swift

override func viewDidLoad() {
  super.viewDidLoad()
  **detailLabel.text = game**
}

@IBAction func selectedGame(segue:UIStoryboardSegue) {
  if let gamePickerViewController = segue.sourceViewController as? GamePickerViewController,
    selectedGame = gamePickerViewController.selectedGame {
    **detailLabel.text = selectedGame**
    game = selectedGame
  }
}
  

Swift编译错误'text'不可用:从iOS 7及更早版本开始使用的API在Swift中不可用

编辑: @IBOutlet weak var detailLabel:UILabel!

但是,

init PlayerDetailsViewController
2015-09-01 14:14:45.050 Ratings[3594:145699] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<Ratings.PlayerDetailsViewController 0x7ff6c3d42e80> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key detailLabelCurrent.'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010483dc65 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x00000001063a8bb7 objc_exception_throw + 45
    2   CoreFoundation                      0x000000010483d8a9 -[NSException raise] + 9
    3   Foundation                          0x0000000104c5bb53 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 259
    4   CoreFoundation                      0x0000000104785d50 -[NSArray makeObjectsPerformSelector:] + 224
    5   UIKit                               0x00000001053b44eb -[UINib instantiateWithOwner:options:] + 1506
    6   UIKit                               0x000000010520c6d8 -[UIViewController _loadViewFromNibNamed:bundle:] + 242
    7   UIKit                               0x000000010520ccc8 -[UIViewController loadView] + 109
    8   UIKit                               0x00000001053d0db8 -[UITableViewController loadView] + 76
    9   UIKit                               0x000000010520cf39 -[UIViewController loadViewIfRequired] + 75
    10  UIKit                               0x000000010520d3ce -[UIViewController view] + 27
    11  UIKit                               0x0000000105246d3b -[UINavigationController preferredContentSize] + 149
    12  UIKit                               0x00000001051eceee -[UIPresentationController preferredContentSizeDidChangeForChildContentContainer:] + 101
    13  UIKit                               0x00000001051ea33d __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 122
    14  UIKit                               0x00000001051005ec _applyBlockToCFArrayCopiedToStack + 314
    15  UIKit                               0x0000000105100466 _afterCACommitHandler + 533
    16  CoreFoundation                      0x0000000104770ca7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    17  CoreFoundation                      0x0000000104770c00 __CFRunLoopDoObservers + 368
    18  CoreFoundation                      0x0000000104766a33 __CFRunLoopRun + 1123
    19  CoreFoundation                      0x0000000104766366 CFRunLoopRunSpecific + 470
    20  GraphicsServices                    0x0000000108811a3e GSEventRunModal + 161
    21  UIKit                               0x00000001050dc8c0 UIApplicationMain + 1282
    22  Ratings                             0x000000010461b357 main + 135
    23  libdyld.dylib                       0x0000000106ade145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

我遇到过这些情况,如何修复这些行以证明所有iOS版本?

0 个答案:

没有答案