MainViewController という名前の UIViewController があります。ViewMaker という名前の別のクラスがあります。ViewMaker クラスには、次のような関数があります。
-(UIView *)GetContentView
{
UIView *return_view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)];
UIButton *done_button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
done_button.frame = CGRectMake(300, 300, 100, 50);
[done_button setTitle:@"Done" forState:UIControlStateNormal];
[return_view addSubview:done_button];
return return_view;
}
上記の関数では、実際にはテキストビュー、ラベルなどのビューをさらに追加します。
MainViewController クラスでは、上記のメソッドを次のように呼び出しています。
-(void)CreateViews
{
UIView *content_view = [[[ViewMaker alloc] init] GetContentView];
[self.view addSubview:content_view];
}
MainViewController クラスから、完了ボタン (およびテキストビュー、ラベルなどの他のコンポーネント) を含むビューを追加しました。私の問題は、完了ボタンのターゲット関数を追加することです。完了ボタンをクリックすると、ViewMaker クラスから返されたビューのデータに従って、MainViewController でいくつかのアクション (いくつかのビューを追加するなど) を実行したいと考えています。これどうやってするの?前もって感謝します。