0

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

下面是代码:

-(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.
4

1 回答 1

0

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

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

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

现在问题已经解决了。

于 2012-04-30T13:18:19.007 回答