【发布时间】:2016-11-29 13:22:56
【问题描述】:
我是 Objective-C、Xcode 和所有好东西的新手。我是自学的。
我正在尝试从另一种方法调用IBAction。
- (IBAction)strAdj:(UIStepper *)strStepper
{
// Converts stepper to integer
NSUInteger strvalue = strStepper.value;
// Changes the the text to the value of the stepper
strStat.text = [NSString stringWithFormat:@"%2d", (unsigned)strvalue];
_strMod.text = [NSString stringWithFormat:@"%2d", (unsigned)stepperAdj(strvalue)];
// Based on the value it change the strMod to a specific value
}
我只发布下一个代码的一部分。这是一个简单的switch 声明。我基本上想在下面的 Void 中调用上面的 IBAction。
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
switch (row) {
case 0:
break;
// Core races never change
// defines dwarf stats
case 1:
// sets all the increases
tempCon = 2;
tempWis = 2;
tempChr = -2;
// resets all other stats
tempStr = 0;
tempDex = 0;
tempInt = 0;
// I want to call the IBAction here...
break;
这个IBAction 最终需要出现 15 次。上面的switch 语句在选择器更改时发生。每次步进器发生时,IBAction 都会发生。
我希望我离我想做的事情不会太远。再说一次,我最近几天一直在处理这个问题,但我找不到我要找的东西,或者如果我找到了,那么我不确定该怎么做。
【问题讨论】:
-
为什么需要从选取器委托方法中调用步进操作?
标签: ios objective-c