我试图问这个问题,但不知怎的,我想我没能正确表达自己,所以我删除了它并重新开始。
我有一个层次结构:- ViewController => UIView => Stepper
这是我的 UIView 代码:-
@implementation Controls
@synthesize m_numColumn=_whatever;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
int i;
m_numColumn= [[UIStepper alloc]init];
m_numColumn.frame = CGRectMake(1, 1, 30, 30);
m_numColumn.autorepeat= FALSE;
[m_numColumn setValue:2];
m_displayColumnNum= [[UILabel alloc]init];
m_displayColumnNum.frame = CGRectMake(30, 30, 60, 30);
// m_displayColumnNum.backgroundColor =lgammaf(<#float#>);
// m_displayColumnNum.text= [NSString stringWithFormat:@"aaaaaa"];
i= m_numColumn.value;
m_displayColumnNum.text= [NSString stringWithFormat:@"%d",i];
[self addSubview:m_numColumn];
[self addSubview:m_displayColumnNum];
// Controls.delegate = [m_numColumn.navigationController.viewControllers objectAtIndex:0];
[m_numColumn addTarget:self action:@selector(stepperChanged:) forControlEvents:UIControlEventTouchUpInside];
//[m_numColumn setdelegate];
}
return self;
}
这里重要的一行是:
[m_numColumn addTarget:self action:@selector(stepperChanged:) forControlEvents:UIControlEventTouchUpInside];
我想要的是在 UIViewController (父对象)中对该事件做出反应。我怎么做?