iphone - NSString stringWithFormat

标签 iphone nsstring stringwithformat

我不知道我在这里错过了什么。我正在尝试使用 [NSString stringWithFormat] 函数连接字符串。这就是我正在做的事情。

NSString *category = [row objectForKey:@"category"];
NSString *logonUser = [row objectForKey:@"username"];
user.text = [NSString stringWithFormat:@"In %@ by %@", category, logonUser];

这里的问题是它总是只打印一个变量。假设类别中有“Sports”并且 logonUser 中有“Leo”,它将打印“In Sports”并跳过其余文本。它应该打印“In Sports by Leo”。

最佳答案

user 是 UILabel 吗?确保您的文本没有换行或被剪裁。尝试使 UILabel 更大。

关于iphone - NSString stringWithFormat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2740191/

相关文章:

ios - 如何处理 UICollectionView 中的后台点击

ios - 以编程方式在 iOS 设置中设置全局 Http 代理的可能方法是什么?

ios - 自定义委托(delegate)不更新 iOS 中的 UI

objective-c - iOS:检测NSData的正确编码

ios - "NSString stringWithFormat:"和 "%zd"在 32 位设备中的奇怪行为

objective-c - stringWithFormat 中的枚举引发不兼容的指针类型警告

iphone - 如何使用stringWithFormat将连字符动态添加到我的字符串中

ios - 自定义 moreNavigationController 的 tableview 和类似的用户界面

ios - 计算可以包含在具有特定大小的容器中的文本

ios - 获取 UIWebview 的当前域