简单delegate(省略版本)

来源:互联网 发布:淘宝发布类目受到限制 编辑:程序博客网 时间:2024/06/05 14:33

设置delegate

.h文件

#import <UIKit/UIKit.h>

@protocol PauseViewDelegate <NSObject>

- (void) Touchstart;

- (void) Touchprevious;

- (void) Touchnext;

- (void) Touchback;

@end


@interface PauseView : UIView

{

}

@property (nonatomic ,assign)id delegate;

@end



.m文件

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event

{

    [super touchesEnded:toucheswithEvent:event];

    UITouch *touch = [touches anyObject];

    CGPoint touchPoint = [touch locationInView:self];

    NSLog(@"end %f==%f",touchPoint.x,touchPoint.y);

    

    [self.delegateTouchpause];

 }





实现delegate

.h文件

没做处理


.m文件

#import "PauseView.h"


@interface ViewController ()

{

   

}

 @property (nonatomic ,strong)PauseView *pauseView;

 @end

 




- (void)viewDidLoad {

    [superviewDidLoad];


    self.pauseView=[[PauseViewalloc]initWithFrame:[UIScreenmainScreen].bounds];

    self.pauseView.backgroundColor=[UIColorclearColor];

    self.pauseView.delegate =self;

    [self.viewaddSubview:self.pauseView];

    


}

//PauseViewDelegate

- (void)Touchpause

{

 NSLog(@"Touchpause");


}






0 0
原创粉丝点击