У меня есть UIButton
, который вызывает метод от другого UIViewController
, этот метод вызывает метод делегата, которого не происходит.Вызов метода делегата не работает
Что-то вроде:
FirstViewController
-(void)viewWillAppear:(BOOL)animated {
//Submit Button
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
action:@selector(someMethod)
forControlEvents:UIControlEventTouchDown];
[button setTitle:@"Submit" forState:UIControlStateNormal];
button.frame = CGRectMake(100.0, 120.0, 80.0, 40.0);
[self addSubview:button];
}
- (void)someMethod {
SecondViewController *viewC = [[SecondViewController alloc] init];
[viewC otherMethod];
}
SecondViewController
- (void)otherMethod {
NSLog(@"Verification.....");
[self.delegate foo:self Bar:self.text]; //not working when called the otherMethod from FirstViewController
}
Я знаю, что я делаю это неправильный путь.
вы можете предоставить немного больше вашего кода, чтобы мы могли видеть, что не так? – zahreelay
Что вы видите, если вы измените строку ведения журнала на 'NSLog (@" Verification .....% @ ", self.delegate);'? –
@PhillipMills Я вижу «Проверка ...... (null)». –