CocoaTouch (iPhone) 中的双倍行距文本视图

Posted

技术标签:

【中文标题】CocoaTouch (iPhone) 中的双倍行距文本视图【英文标题】:Double-spaced textview in CocoaTouch (iPhone) 【发布时间】:2010-04-23 09:49:44 【问题描述】:

我可以有一个双倍行距的 UITextView 吗?我的意思是,以便在我编辑它时保留它的格式?

我需要在文本行之间显示图形元素。有什么想法吗?

谢谢!

【问题讨论】:

【参考方案1】:

抱歉,回答错了问题。

这里有问题的答案: iPhone: Disable the "double-tap spacebar for ." shortcut?

把它放在你的委托类中:

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string


 //Check for double space

 if (range.location > 0 && [[NSCharacterSet whitespaceCharacterSet] characterIsMember:[string characterAtIndex:0]] && [[NSCharacterSet whitespaceCharacterSet] characterIsMember:[[textField text] characterAtIndex:range.location - 1]])
  return NO;

return YES;

【讨论】:

以上是关于CocoaTouch (iPhone) 中的双倍行距文本视图的主要内容,如果未能解决你的问题,请参考以下文章