我有一个带有三个按钮的 View 。
当按下其中任何一个时,它会调用一个带有另一个按钮的自定义 UIView。
我想做的是将自定义 View 按钮更改为不同的操作,具体取决于调用新 View 的按钮。
希望这是有道理的。
谢谢
最佳答案
我建议您为自定义 View 动态创建按钮:
CGRect buttonFrame = CGRectMake( 10, 280, 100, 30 );
UIButton *button = [[UIButton alloc] initWithFrame: buttonFrame];
[button setTitle: @"My Button" forState: UIControlStateNormal];
[self.view addSubview: button];
if(//clicked button 1)
{
[button addTarget: self
action: @selector(action1:)
forControlEvents: UIControlEventTouchDown];
}
else if(//clicked button 2)
{
[button addTarget: self
action: @selector(action2:)
forControlEvents: UIControlEventTouchDown];
}
else
{
[button addTarget: self
action: @selector(action3:)
forControlEvents: UIControlEventTouchDown];
}
关于ios - 更改 UIView 按钮操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13200425/