有谁知道是否有办法确定是否存在具有特定名称的 segue?或者,如果有办法获取 iOS 知道的所有命名 segue 的列表
问问题
2222 次
3 回答
2
不,您的方法仅检测何时触发特定的 segue。但是您无法通过尝试调用它的另一种方式来测试是否存在segue。似乎唯一的方法是使用 @try @catch :
@try {
[self performSegueWithIdentifier:@"Replace_Connected" sender:self];
}
@catch (NSException *exception) {
NSLog(@"%@ no segue with identifier 'Replace_Connected' : %@", [self description], exception);
}
@finally { }
于 2013-01-16T01:29:11.203 回答
2
我建议你提交一个错误。故事板清楚地知道来自给定场景的所有转场:
<viewController id="2" customClass="ViewController" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="3">
<rect key="frame" x="0.0" y="20" width="320" height="460"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
<connections>
<segue destination="t3N-Fe-gqq" kind="modal" identifier="myCoolSegue" id="AYQ-C4-4vO"/>
</connections>
</viewController>
那么为什么不允许视图控制器实例询问该信息呢?此外,视图控制器有一个storyboard
属性,为什么它没有一个segues
属性?我认为您有正当理由提出功能请求。
于 2013-01-16T02:39:09.517 回答
-2
您可以使用以下方法检查 Segue 是否存在prepareForSegue
:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Make sure we are dealing with the proper Segue
if ([segue.identifier isEqualToString:@"MySegueID"]) {
// Exists, do something
}
}
如果有办法列出所有 Segue,我不知道,也没有在文档中看到它。
于 2012-04-03T00:32:22.943 回答