Ios 向uibutton标题添加字符串
我正在尝试根据数组中的字符串更新按钮的标题字符串nextplayername工作正常,但是我正在努力使后面的文本显示出来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
[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] ...
第一件事:把
你的
改成你的
你问之前有没有用谷歌搜索过这个?这是一件非常简单的事情,可以保证它是许多在线教程的一部分。是的,我花了几个小时伤心地寻找,不知道要找什么。