0
Newbee的問題在這裏 -目標C如何調用視圖控制器的方法從子視圖
我在視圖控制器M這個方法:
-(void) backToHP:(id<SwitchViewProtocol>) fromView{
[(UIView *)self.currentView removeFromSuperview];
[self.currentView clearView];
[self.view addSubview:_hpView];
self.currentView = nil;
CATransition *animation = [CATransition animation];
[animation setDuration:0.2];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromLeft];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[self.view layer] addAnimation:animation forKey:@"SwitchToView1"];
}
我嘗試從一個子類調用它。 子類H:
@interface SetNotificationClass : UIView < SwitchViewProtocol> {
habitsViewController *hvc;
}
@property (nonatomic, retain) habitsViewController *hvc;
子L:
@synthesize hvc;
- (IBAction)saveNotificationClick:(id)sender {
// [self scheduleAlarm];
[hvc backToHP:nil];
}
我得到錯誤 「找不到方法」。任何想法?
感謝
您應該使用委託並將您的hvc設置爲其子視圖的代表。 – shannoga
什麼是'habitViewController'?我們需要查看代碼的其餘部分。 (另外,'方法未找到'編譯時或運行時錯誤?) – Vervious