Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 向uibutton标题添加字符串_Ios_Objective C_Nsstring_Uibutton - Fatal编程技术网

Ios 向uibutton标题添加字符串

Ios 向uibutton标题添加字符串,ios,objective-c,nsstring,uibutton,Ios,Objective C,Nsstring,Uibutton,我正在尝试根据数组中的字符串更新按钮的标题字符串nextplayername工作正常,但是我正在努力使后面的文本显示出来 [self.shownextbutton setTitle:nextplayerName @"Your Up! " forState:UIControlStateNormal]; 基本上,我希望按钮标题显示以下“nextplayername字符串”您的页面 试试看: ... setTitle:[NSString stringWithFormat:@"%@ You're U

我正在尝试根据数组中的字符串更新按钮的标题字符串nextplayername工作正常,但是我正在努力使后面的文本显示出来

 [self.shownextbutton setTitle:nextplayerName @"Your Up! " forState:UIControlStateNormal];
基本上,我希望按钮标题显示以下“nextplayername字符串”您的页面

试试看:

... setTitle:[NSString stringWithFormat:@"%@ You're Up!", nextplayerName] ...
使用格式规范从所需内容创建字符串

或者,将字符串附加在一起:

NSString *title = [nextplayerName stringByAppendingString:@" You're Up!"];
... setTitle:title ...
更好地支持本地化:

... setTitle:[NSString stringWithFormat:NSLocalizedString(@"%@ You're Up!", @"Batter up!"), nextplayerName] ...

第一件事:把
你的
改成
你的
你问之前有没有用谷歌搜索过这个?这是一件非常简单的事情,可以保证它是许多在线教程的一部分。是的,我花了几个小时伤心地寻找,不知道要找什么。