在设备上分配UIPickerView值问题

时间:2012-04-08 14:32:06

标签: iphone ios xcode xcode4.2

我在设备上面临这个问题,分配所选择的选择行值需要花费太多时间才能在标签上显示,而在模拟器上运行正常。

以下是代码:

-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row
      inComponent:(NSInteger)component
{
    if (pickerView == rewardsName) {

    NSString *selectedReward = [self.rewards objectAtIndex:row];

    if ([reward1.text length]==0){
        //set label 1

        reward1.text = selectedReward;
    }
    if ([reward2.text length]==0){
        //set label 2

        reward2.text = selectedReward;
    }
    if([reward3.text length]==0){
        //set label 3.

        reward3.text = selectedReward;
    }
    }

    else if(pickerView == selectNamazPicker){

        aNumberString = [self.namazArray objectAtIndex:row];

        NSLog(@"aNumberString:: %@", aNumberString);
    } 
}

谁能告诉我可能是什么问题......我找不到一个......

**

EDITED:
ISSUE RESOLVED:

**

For others who would face this issue.

I don't know whether it was creating the problem or not. But I did make these changes to my code.

In my .h file, previously I was just defining properties of UILabels (reward1, reward2 etc) with IBOutlet and not ivars. But then I defined ivars as IBOutlet UILabel reward1; etc and eliminated IBOutlet from properties then it started working fine. 

Now the problem has resolved.

1 个答案:

答案 0 :(得分:0)

对于其他将面临此问题的人。

我不知道是不是在创造问题。但我确实对我的代码进行了这些更改。

在我的.h文件中,之前我只是用IBOutlet定义了UILabels(reward1,reward2等)的属性而不是ivars。但后来我将ivars定义为IBOutlet UILabel reward1;等从属性中消除IBOutlet然后它开始正常工作。

现在问题已经解决了。