简体   繁体   English

未调用委托方法:IOS 6

[英]Delegate method not called : IOS 6

I have a ConfirmClaimViewcontroller.h which defines a delegate as: 我有一个ConfirmClaimViewcontroller.h ,它将委托定义为:

@protocol ClaimConfirmedDelegate<NSObject>
@required
- (void) claimConfirmedDelegate : (NSInteger) tag;
@end

@interface ConfirmClaimControllerViewController : UIViewController{
    id <ClaimConfirmedDelegate> delegate;
}

-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil withTag:(NSInteger)tag;

@property(nonatomic,assign)id delegate;

@end

I define the delegate in ClaimViewController.m : 我在ClaimViewController.m定义委托:

- (void) claimConfirmedDelegate:(NSInteger)tag{
    NSLog(@"Delegate called");
}

I call the ConfirmClaimViewController as below ( its a popup) : 我将ConfirmClaimViewController调用如下(它是一个弹出窗口):

   ConfirmClaimControllerViewController *confirmClaimController=[[ConfirmClaimControllerViewController alloc] initWithNibName:@"ConfirmClaim" bundle:nil withTag:sender.view.tag];
    confirmClaimController.delegate = self;
    [self.view addSubview:confirmClaimController.view];
    [confirmClaimController didMoveToParentViewController:self];
    [self addChildViewController:confirmClaimController];

The popup has two buttons. 弹出窗口有两个按钮。 One one of the button is clicked, this code is called : 单击一个按钮,此代码称为:

if([self.delegate respondsToSelector:@selector(claimConfirmed:)])
{
    [self.delegate claimConfirmedDelegate:self.tagId];
}


[self.view removeFromSuperview];
[self removeFromParentViewController];

This is supposed to call the delegate method and then remove the child from view. 这应该调用委托方法,然后从视图中删除子节点。 Child gets removed but delegate is never called. 子项被删除但从未调用委托。 I'm new to this , any help would be appreciated. 我是新手,任何帮助将不胜感激。

This line: 这一行:

if([self.delegate respondsToSelector:@selector(claimConfirmed:)])

Should be: 应该:

if([self.delegate respondsToSelector:@selector(claimConfirmedDelegate:)])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM