当我点击该行时,未调用dIDSelectRowAtIndex.
有人知道我哪里错了,我怎么能传递字符串?
tableInterfaceController
不调用dIDSelectRowAtIndexPath打印语句
@IBOutlet var table: WKInterfacetable!var objectsArray = ["1","2","3"]var object: String!overrIDe func table(table: WKInterfacetable,dIDSelectRowAtIndex rowIndex: Int) { self.object = self.objectsArray[rowIndex] print(" object Title: \(self.object)")}overrIDe func contextForSegueWithIDentifIEr(segueIDentifIEr: String) -> AnyObject? { // You may want to set the context's IDentifIEr in Interface Builder and check it here to make sure you're returning data at the proper times // Return data to be accessed in ResultsController return self.object}
DetailsInterfaceController
标签未设置
@IBOutlet var label: WKInterfaceLabel!overrIDe func awakeWithContext(context: AnyObject?) { super.awakeWithContext(context) // Make sure data was passed properly and update the label accordingly if let val: String = context as? String { self.label.setText(val) } else { self.label.setText("") } // Configure interface objects here.}解决方法 为什么不叫:
表格是正常的:dIDSelectRowAtIndex:因为你使用了故事板segue而没有被调用.从WKInterfaceController
文档:
If you connected an action method to the table in your storyboard file,WatchKit does not call this method.
如何传递选定的行数据:
您应该使用contextForSegueWithIDentifIEr:intable:rowIndex:返回所选行的上下文:
overrIDe func contextForSegueWithIDentifIEr(segueIDentifIEr: String,intable table: WKInterfacetable,rowIndex: Int) -> AnyObject? { if segueIDentifIEr == "someSegueIDentifIEr" { return objectsArray[rowIndex] } return nil}总结
以上是内存溢出为你收集整理的ios – 没有为WKInterfaceTable调用didSelectRowAtIndex全部内容,希望文章能够帮你解决ios – 没有为WKInterfaceTable调用didSelectRowAtIndex所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)