@selector key word in iPhone programming

前端 未结 3 1715
误落风尘
误落风尘 2021-01-24 09:40

-(void)displayNameBy:(NSString*)name{

    mylable.text = name;

}

i want call this method using @selector keywords.

eg:



        
3条回答
  •  逝去的感伤
    2021-01-24 10:08

    Have an intermediate method. like:

    {
       ...
       [MyButton addTarget:self action:@selector(displayName) forControlEvents:UIControlEventTouchUpInside];
       ...
    }
    
    -(void) displayName
    {
       [self performSelector:@selector(displayNameBy:) withObject:@"name"];
    }
    
    -(void)displayNameBy:(NSString*)name{
    
        mylable.text = name;
    
    }
    

提交回复
热议问题