<分区>
<分区>
我试了所有方法都没有用,因为我的逻辑能力很差......问题是我需要用uitextfield替换句子中的一个词,这样它看起来像一个空白,而且太动态了
例如:测试到达现场
我需要用 UItextfield 替换上面句子中的“Test”,以便用户可以输入 uitextfield。请告诉我如何替换它..
我用uitextview来展示问题,代码是
UITextview *textview = [[UITextView alloc] initWithFrame:CGRectMake(0.0, currentY, 320.0, myStringSize.height)];
textview.text = [NSString stringWithFormat:@"%i. %@", i+1, unhide];
textview.font = [UIFont fontWithName:@"Helvetica" size:16.0f];
CGRect frame = textview.frame;
frame.size.height = textview.contentSize.height;
textview.frame = CGRectMake(0.0, currentY, 320.0, frame.size.height+20);
textview.editable = NO;
[scrollMain addSubview:textview];
有没有办法做到...
或者有什么方法可以在 TextView 中找出“测试”的坐标吗? 帮帮我,先谢谢了。
最佳答案
这会将单词“Test”替换为您选择的字符串:
textview.text = [textview.text stringByReplacingOccurrencesOfString:@"test" withString:@"SomeStringToReplaceWithTest"];
关于ios - 如何用 UItextfield 替换特定字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14560735/