如果我UIView
(MyUIView
)聲明並@synthesize
(S)在Objective-C的代表,澄清需要
@property (nonatomic, weak) id<UIScrollViewDelegate> delegate;
和MyController
被聲明爲
@interface MyController : UIViewController <UIScrollViewDelegate>
,並符合下列條件(內myController的)
if ([self.view isKindOfClass:[MyUIView class]]){
NSLog(@"yes"); // We see this
}
爲什麼會出現以下問題?
self.view.delegate = self; // Does not see "delegate"
同時,如果我手動創建MyView的實例,它的工作原理:
MyView *c = [MyView new];
c.delegate = self; // works fine