【发布时间】:2015-03-14 23:37:08
【问题描述】:
我有一个带有表格视图的 InterfaceController。我从 tableview 的一个单元格创建了一个 segue 到另一个 InterfaceController。如果 segue 类型是“Push”,则调用 contextForSegueWithIdentifier。如果类型是“模态”,则不会调用 contextForSegueWithIdentifier。
【问题讨论】:
我有一个带有表格视图的 InterfaceController。我从 tableview 的一个单元格创建了一个 segue 到另一个 InterfaceController。如果 segue 类型是“Push”,则调用 contextForSegueWithIdentifier。如果类型是“模态”,则不会调用 contextForSegueWithIdentifier。
【问题讨论】:
没关系。根据文档 contextForSegueWithIdentifier 仅在 Push Segue 上被调用。我需要使用
- (void)table:(WKInterfaceTable *)table didSelectRowAtIndex:(NSInteger)rowIndex
tableview的调用方法
-(void)presentControllerWithNames:(NSArray *)names contexts:(NSArray *)contexts
【讨论】:
使用表格视图时,请使用此 segue 方法将对象传递给您的 segue。
- (id)contextForSegueWithIdentifier:(NSString *)segueIdentifier inTable:(WKInterfaceTable *)table rowIndex:(NSInteger)rowIndex {
return yourObject;
}
【讨论】: