Tag: uitextview xcode4.5

从UITextView获取文本的来源

– 目标:在UITextView中获取文本的特定部分的来源 以下是我正在处理的应用程序的屏幕截图的链接。 请看,因为它更容易解释。 图片链接: ScreenShot 这是一个填补空白风格的游戏的开始。 我目前正在尝试获取每个下划线的x,y坐标。 当点击屏幕底部的一个单词时,它将移动到下一个可用的下划线空间。 目前我已经写了这个代码来做我所需要的,但是它非常难看,几乎没有工作,并且不是很灵活。 见下文: // self.mainTextView is where the text with the underscores is coming from NSString *text = self.mainTextView.text; NSString *substring = [text substringToIndex:[text rangeOfString:@"__________"].location]; CGSize size = [substring sizeWithFont:self.mainTextView.font]; CGPoint p = CGPointMake((int)size.width % (int)self.mainTextView.frame.size.width, ((int)size.width / (int)self.mainTextView.frame.size.width) * size.height); // What is going on here […]