1

我正在实现我的 UIViewController 类的协议。我需要在另一个类中执行此协议的方法。但它不起作用。

下面是代码。请帮帮我。

///This is my Header Class

#import <UIKit/UIKit.h>

@protocol PauseViewDelegate <NSObject>

- (IBAction)ResumeButtonPressed:(id)sender;
- (IBAction)MenuButtonPressed:(id)sender;
- (IBAction)RestartButtonPressed:(id)sender;

@end

@interface PauseViewController : UIViewController

@property (nonatomic, retain) id<PauseViewDelegate> pauseDelegate;

@end



////This is implementation class protocol Methods.

#import "PauseViewController.h"

@interface PauseViewController ()

@end

@implementation PauseViewController
@synthesize pauseDelegate;

- (IBAction)ResumeButtonPressed:(id)sender
{
    NSLog(@"resume delegate");
        [pauseDelegate ResumeButtonPressed:sender];

}
- (IBAction)RestartButtonPressed:(id)sender
{
    NSLog(@"Restart delegate");
    [self.view removeFromSuperview];
    [pauseDelegate RestartButtonPressed:sender];
}
- (IBAction)MenuButtonPressed:(id)sender
{
    NSLog(@"Menu delegate");
    [self.view removeFromSuperview];
    [pauseDelegate MenuButtonPressed:sender];
}

我在不同的视图控制器中使用这些方法,但它不起作用。

4

0 回答 0