1
我的應用程序的每一個的UIViewController管理iboutlets使用的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 */
}
現在我試圖創建基礎視圖控制器,這樣我就可以圍繞繼承使用它,重用這些方法。在基本視圖控制器responder
物業工作得很好,因爲委託的UITextField設置它的值,但滾動型是一個IBOutlet中,我真的不知道如何設計這個基類:
#import "ViewControllerBase.h"
@interface ViewControllerBase()
@property (weak, nonatomic) UIView* responder;
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView; /* ??? */
@end
@implementation ViewControllerBase
-- methods
@end