프로젝트를 실행할 때 다음 오류가 나타납니다. secView.delegate=self;
위의 문제를 어떻게 해결할 수 있습니까? 감사!'UIViewController *'유형의 'delegate'객체가 없습니다.
재산권 '위임'객체는 bookmarkViewController.h
유형 '의 UIViewController *'
myViewController.h
@interface myViewController : UIViewController <UITextFieldDelegate,UIAlertViewDelegate,secondViewControllerDelegate>
- (IBAction)popBookmarkTable:(id)sender;
myViewController.m
- (IBAction)popBookmarkTable:(id)sender {
UIStoryboard *st = [UIStoryboard storyboardWithName:[[NSBundle mainBundle].infoDictionary objectForKey:@"UIMainStoryboardFile"] bundle:[NSBundle mainBundle]];
UIViewController *secView = [st instantiateViewControllerWithIdentifier:@"bookmarkViewController"];
[self presentViewController:secView animated:YES completion:nil];
secView.delegate=self;
}
- (void)passData:(NSString *)data
{
_addressBar.text=data;
}
를 찾을 수 없습니다즉 일반 UIViewController
- 당신이 secView
를 선언하면
@protocol secondViewControllerDelegate <NSObject>
@required
- (void)passData:(NSString *)data;
@end
@property (nonatomic, weak) id<secondViewControllerDelegate> delegate;
@property (nonatomic,strong) NSString *a;
@end
bookmarkViewController.m는
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell * cell = [tableView cellForRowAtIndexPath:indexPath];
if ([indexPath row]==0) {
_a=(NSString *)cell.textLabel.text;
[_delegate passData:_a];
[self dismissViewControllerAnimated:YES completion:nil];
}
}
정말 멋지다. 고마워요! – floyddd
그냥 바꾸기 UIViewController * menuVC = [[MenuViewController alloc] initWithNibName : @ "MenuViewController"번들 : nil]; 에 MenuViewController * menuVC = [[MenuViewController alloc] initWithNibName : @ "MenuViewController"번들 : nil]; – dip