Ios 在一个标签字符串中显示两种不同类型的变量
我试图使一个Ios 在一个标签字符串中显示两种不同类型的变量,ios,objective-c,string,cclabelttf,Ios,Objective C,String,Cclabelttf,我试图使一个CCLabelTTF同时显示一个字符串和一个整数。像这样: 你的分数是0 我尝试了一些方法,但我通常会得到格式字符串未使用的警告数据参数,并且标签不会输出正确的语句 我只是想弄清楚这些内容的格式,搜索谷歌并没有提供太多,因为我真的不确定到底要搜索什么 我试过了 label.string=(@“%@”,“hi”,“d”,investmentsPurchased) 但显然这是不对的。我该怎么做 谢谢。(我想这是ObjC,不是Swift。)试试这样的方法: label.string = [
CCLabelTTF
同时显示一个字符串和一个整数。像这样:
你的分数是0
我尝试了一些方法,但我通常会得到格式字符串未使用的警告数据参数,并且标签不会输出正确的语句
我只是想弄清楚这些内容的格式,搜索谷歌并没有提供太多,因为我真的不确定到底要搜索什么
我试过了
label.string=(@“%@”,“hi”,“d”,investmentsPurchased)
但显然这是不对的。我该怎么做
谢谢。(我想这是ObjC,不是Swift。)试试这样的方法:
label.string = [NSString stringWithFormat:@"hi %d", investmentsPurchased];
您使用一个单一格式的字符串,其中包含静态文本和任何替换变量的替换标记(如%d
)。然后按照要在中替换的值列表进行操作。您可以使用多个变量,如:
label.string = [NSString stringWithFormat:@"number %d and a string %@", someInteger, someString];
(我假设这是ObjC,而不是Swift。)尝试以下方法:
label.string = [NSString stringWithFormat:@"hi %d", investmentsPurchased];
您使用一个单一格式的字符串,其中包含静态文本和任何替换变量的替换标记(如%d
)。然后按照要在中替换的值列表进行操作。您可以使用多个变量,如:
label.string = [NSString stringWithFormat:@"number %d and a string %@", someInteger, someString];
(我假设这是ObjC,而不是Swift。)尝试以下方法:
label.string = [NSString stringWithFormat:@"hi %d", investmentsPurchased];
您使用一个单一格式的字符串,其中包含静态文本和任何替换变量的替换标记(如%d
)。然后按照要在中替换的值列表进行操作。您可以使用多个变量,如:
label.string = [NSString stringWithFormat:@"number %d and a string %@", someInteger, someString];
(我假设这是ObjC,而不是Swift。)尝试以下方法:
label.string = [NSString stringWithFormat:@"hi %d", investmentsPurchased];
您使用一个单一格式的字符串,其中包含静态文本和任何替换变量的替换标记(如%d
)。然后按照要在中替换的值列表进行操作。您可以使用多个变量,如:
label.string = [NSString stringWithFormat:@"number %d and a string %@", someInteger, someString];
使用NSString newString=[NSString stringWithFormat:@“hello%@”,investmentsPurchased]代码>
简而言之:使用stringWithFormat
使用NSString newString=[NSString stringWithFormat:@“hello%@”,investmentsPurchased]代码>
简而言之:使用stringWithFormat
使用NSString newString=[NSString stringWithFormat:@“hello%@”,investmentsPurchased]代码>
简而言之:使用stringWithFormat
使用NSString newString=[NSString stringWithFormat:@“hello%@”,investmentsPurchased]代码>
简而言之:使用stringWithFormat