私のアプリのすべての UIViewController は、次のような UITextField デリゲートを使用しています。
- (void)textFieldDidBeginEditing:(UITextField*)textField {
self.responder = textField;
}
- (BOOL)textFieldShouldReturn:(UITextField*)textField {
double elementYPosition = self.responder.frame.origin.y;
double elementHeight = self.responder.frame.size.height;
double scrollYPosition = self.scrollView.contentOffset.y;
/* some logic */
}
今、私は基本的なView Controllerを作成しようとしているので、メソッドを再利用して、それを継承して使用することができます。UITextField デリゲートがその値を設定するため、基本ビュー コントローラーのresponder
プロパティは正常に機能しますが、スクロール ビューは IBOutlet であり、この基本クラスを設計する方法がよくわかりません。
#import "ViewControllerBase.h"
@interface ViewControllerBase ()
@property (weak, nonatomic) UIView* responder;
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView; /* ??? */
@end
@implementation ViewControllerBase
-- methods
@end