クラスAがあり、クラスBIがクラスAからクラスBを呼び出しています。ここで私の問題は、クラスAの幅と高さがクラスBに依存していることです。sizeForScrollView
プロパティ(クラスBプロパティ)が変更されたとき、通知が必要です。クラスBの通知ラインからクラッシュしているときに、クラスAをリロードしています。
コードは次のとおりです。
クラスA
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector (changeContentSize) name:@"MyNotification" object:nil];
-(void)changeContentSize{
self.scrollView.contentSize = CGSizeMake(self.aSubjectView.sizeForScrollView.width, self.aSubjectView.sizeForScrollView.height);
self.aSubjectView.frame = CGRectMake(frameForView.origin.x, frameForView.origin.y, frameForView.size.width, self.aSubjectView.sizeForScrollView.height);
}
クラスB
CGRect rect;
rect.size.width = self.frame.size.width;
rect.size.height = heightForSubject + 10;
rect.origin = self.frame.origin;
sizeForScrollView = rect.size;
NSNotification* notification = [NSNotification notificationWithName:@"MyNotification" object:self];
[[NSNotificationCenter defaultCenter] postNotification:notification];
助けてください。ありがとうございます。