将tableview中的文本转换为大写字母?

时间:2012-11-25 14:24:23

标签: iphone ios xcode tableview

我正在研究RSS提要,需要将标题和副标题转换为大写字母,有没有简单的方法可以做到这一点?

enter image description here

感谢。

4 个答案:

答案 0 :(得分:3)

在cellForRow AtIndexPath

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];

NSString *string1 = @"The quicK brOwn fox jumpeD";

cell.textLabel.text = [string1 uppercaseString];

....

答案 1 :(得分:1)

NSString* str = @"abcd abcd abcd abcd";
[str capitalizedString];    //  = Abcd Abcd Abcd Abcd
[str uppercaseString];      //  = ABCD ABCD ABCD ABCD

答案 2 :(得分:0)

uppercaseString NSString的方法

答案 3 :(得分:0)

您可以在文本字段属性下的故事板中执行此操作。 将Capitalization下拉列表更改为All Characters。在您的设备上测试它或确保键盘打开。如果您从物理键盘输入,它将覆盖模拟器键盘上的大写字母箭头。