Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/93.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 在xcode中修复标签文本的正确方法是什么?_Ios_Objective C_Uilabel - Fatal编程技术网

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];

作为将来的参考-永远不要使用“不起作用”这个词。那些话毫无意义。实际描述问题。它应该做什么?到底发生了什么?如果有错误,请包含准确完整的错误消息。