私のビュー コントローラー StartViewController は、他の 2 つのビュー コントローラー (RootViewController または TelnetAddressbookViewController) のいずれかによって開かれ、追加されます (addSubview)。これらの 2 つのうちどれが StartViewController を起動したのかを把握しようとしています。
NSLog(@"superview %@",self.view.superview.description);
NSLog(@"superview %@",self.superclass);
if ([self.view.superview isKindOfClass:[RootViewController class]]) {
NSLog(@"launched by RootViewController");
}else if ([self.view.superview isKindOfClass:[TelnetAddressbookViewController class]]) {
NSLog(@"launched TelnetAddressbookViewController");
}
[self.view removeFromSuperview];
最初の NSLOG (self.view.superview.description) の出力:
スーパービュー UIView: 0x81d6710; フレーム = (0 0; 748 1024); 変換 = [0, 1, -1, 0, 0, 0]; 自動サイズ変更 = RM+BM; 層 = >
その参照は必要なもの (0x81d6710) ですが、そのクラスはカスタム ビュー コントローラーではなく UIViewController です。