カスタムデリゲートの初期化について質問があります。MyScrollView initWithFrameメソッド内に、デリゲートを送信する必要がある最初の位置があります。しかし、イニシャライザの後にMyCustomView内にデリゲートを設定したため、まだ不明です。
どうすればそれを修正できるので、init内でもデリゲートが呼び出されますか?ご協力いただきありがとうございます..
MyCustomView.m
self.photoView = [[MyScrollView alloc] initWithFrame:frame withDictionary:mediaContentDict];
self.photoView.delegate = self;
//....
MyScrollView.h
@protocol MyScrollViewDelegate
-(void) methodName:(NSString*)text;
@end
@interface MyScrollView : UIView{
//...
__unsafe_unretained id <MyScrollViewDelegate> delegate;
}
@property(unsafe_unretained) id <MyScrollViewDelegate> delegate;
MyScrollView.m
-(id) initWithFrame:(CGRect)frame withDictionary:(NSDictionary*)dictionary{
self.content = [[Content alloc] initWithDictionary:dictionary];
self = [super initWithFrame:frame];
if (self) {
//.... other stuff
// currently don´t get called
[self.delegate methodName:@"Test delegate"];
}
return self;
}