Objective C - loop to change label text

前端 未结 4 1145
礼貌的吻别
礼貌的吻别 2020-11-30 15:08

i have a loop that looks like this

for(int x=0; x < 10; x++){
    [testLabel setText:[self randomString]];
    sleep(1);
}

The randomStr

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-30 15:16

    The UI is only updated at the end of a run loop, of which your loop is running inside of a single iteration of. You should be using an NSTimer instead.

提交回复
热议问题