在 UILabel 中打印字母
大家好, 在我的iPhone应用程序中想要在UILabel中逐个打印一系列字符串,但现在只显示最终的字符串。 我已经尝试过 NSTIMER,但它不起作用。 任何人都可以帮助我。提前致谢
这是我的代码:
//changing strings to char
char *cname1=[n1 cStringUsingEncoding:NSASCIIStringEncoding];
char *cname2=[n2 cStringUsingEncoding:NSASCIIStringEncoding];
for (int i = 0; i < [n1 length]; i++)
{
for (int j = 0; j < [n2 length]; j++){
if ((cname1[i]==cname2[j]))
{
cname1[i]='*';
cname2[j]='*';
myString1 = [NSString stringWithFormat:@"%s", cname1];
myString2 = [NSString stringWithFormat:@"%s", cname2];
[self printlabel];
break;
}
}
-(void)printlabel{
nam1.text = myString1; //set label1
nam2.text = myString2; //set label2
}
Hai all,
In my iPhone app want to print a series of strings in UILabel one by one,but only the final string is displaying now.
I have tried NSTIMER,but it doesn't work.
can anyone help me.thanks in advance
Here is my code:
//changing strings to char
char *cname1=[n1 cStringUsingEncoding:NSASCIIStringEncoding];
char *cname2=[n2 cStringUsingEncoding:NSASCIIStringEncoding];
for (int i = 0; i < [n1 length]; i++)
{
for (int j = 0; j < [n2 length]; j++){
if ((cname1[i]==cname2[j]))
{
cname1[i]='*';
cname2[j]='*';
myString1 = [NSString stringWithFormat:@"%s", cname1];
myString2 = [NSString stringWithFormat:@"%s", cname2];
[self printlabel];
break;
}
}
-(void)printlabel{
nam1.text = myString1; //set label1
nam2.text = myString2; //set label2
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设您在
NSMutableArray
中有 10 个UILabel
。使用下面的代码作为参考。
showElapsedTime
将在您提供的 2.0 秒延迟后调用。调用 startDisplayingLabel 一次,我将在 2.0 秒后显示每个 UILabel。
Let's suppose, you have 10
UILabel
inNSMutableArray
.Use the below code as reference.
showElapsedTime
will be called after 2.0 second of delay, you provide.Call startDisplayingLabel once, i will display each UILabel after exactly 2.0 second.
可能 NSThread将帮助您
尝试将代码更改为,
Probably NSThread will help you
Try changing your code as,