考えられる1つの方法は、SecondViewControllerのビューのsuperViewを使用することです。これは非常に簡単な方法です。
[[self.view superview] insertSubview:theView aboveSubview:self.view];
別の方法は、デリゲートを使用することです。SecondViewControllerでデリゲートを次のように宣言できます
@protocol SecondViewControllerDelegate : NSObject
{
- (void)requestInsertView:(UIView*)view aboveView:(UIView*)baseView;
}
@interface SecondViewController <...>
@property (nonatomic, assign) id<SecondViewControllerDelegate>superViewDelegate;
@end;
そして、FirstViewControllerの宣言を変更して、SecondViewControllerDelegateを実装します。
@interface FirstViewController <SecondViewControllerDelegate, ...>
@implement FirstViewController
- (void)requestInsertView:(UIView*)view aboveView:(UIView*)baseView
{
[self.view insertView:view aboveSubview:baseView];
}
@end;
SecondViewControllerが作成されたら、そのsuperViewDelegateをFirstViewControllerのインスタンスに設定します。
SecondViewControllerからビューを追加する必要がある場所で、
[self.superViewDelegate requestInsertView:view aboveView:self.view];