문제

I have this code:

UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *imgIcon = imageNamed(@"icon_1.png");
[btn1 setImage:imgIcon forState:UIControlStateNormal];

CGPointMake(textField.frame.size.width+textField.frame.origin.x+btnTalk.frame.size.width/2, textField.frame.origin.y+textField.frame.size.height/2);
[btnTalk addTarget:textField action:@selector(Hello:) forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:btnTalk];

i can tap in UIbutton and it works but i want to call with other button i want create one IBAction for call this UIButton

i writes this code but doesn't work & textfield is (objectOfAnotherClass)

-(IBAction)call1
{
    [textField Hello];
}
도움이 되었습니까?

해결책

I think you should do like this:

[btnTalk addTarget:self action:@selector(Hello:) forControlEvents:UIControlEventTouchUpInside];

-(IBAction)call1
{
   [self Hello:nil];
}

다른 팁

I think that you are looking for sendActionsForControlEvents that helps you to 'simulate' the action of touching the button... Here the method description.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top