Ios 在xcode中修复标签文本的正确方法是什么?
这是我的代码:Ios 在xcode中修复标签文本的正确方法是什么?,ios,objective-c,uilabel,Ios,Objective C,Uilabel,这是我的代码: [_HintLabel setText:[NSString stringWithFormat:@"%@", [lst_word objectAtIndex:nCurrentWord]]]; [_HintLabel.stringByPaddingToLength:prlt.length withString: @"~" startingAtIndex:0]; 但是第二行代码不起作用 如何修复它使其正常工作?我相信您希望: NSString *newText = [_Hi
[_HintLabel setText:[NSString stringWithFormat:@"%@", [lst_word objectAtIndex:nCurrentWord]]];
[_HintLabel.stringByPaddingToLength:prlt.length withString: @"~" startingAtIndex:0];
但是第二行代码不起作用
如何修复它使其正常工作?我相信您希望:
NSString *newText = [_HintLabel.text stringByPaddingToLength:prlt.length withString: @"~" startingAtIndex:0];
_HintLabel.text = newText;
顺便说一句-如果数组中的对象已经是字符串,则问题的第一行不需要stringWithFormat:
。只要做:
_HintLabel.text = lst_word[nCurrentWord];
作为将来的参考-永远不要使用“不起作用”这个词。那些话毫无意义。实际描述问题。它应该做什么?到底发生了什么?如果有错误,请包含准确完整的错误消息。