TextView突出显示文本疑惑

时间:2011-10-10 08:47:10

标签: iphone

我正在做一个圣经应用程序,我已经完成了textview中的经文显示。当我点击一个我不应该突出显示的经文时,我感到震惊。我不知道该怎么做。我提供了一个图像网址到表明我想要这样。 提前致谢

.image

1 个答案:

答案 0 :(得分:1)

文本视图通过双击文本视图有一些属性我们可以获得高亮的行,因为你问这是下面的示例代码

.h文件

{
    UITextView *textView;
}
@property (nonatomic, retain) UITextView *text

.m文件

-(void)setupTextView
{
   self.textView = [[[UITextView alloc] initWithFrame:self.view.frame] autorelease];
   self.textView.textColor = [UIColor blackColor];
   self.textView.font = [UIFont fontWithName:@"Arial" size:18];
   self.textView.delegate = self;
   self.textView.backgroundColor = [UIColor whiteColor];

   self.textView.text = @"Hello this is about the text view, the difference in text view and the text field is that you can display large data or paragraph in text view but in text field you cant.";
   self.textView.returnKeyType = UIReturnKeyDefault;
   self.textView.keyboardType = UIKeyboardTypeDefault;  // use the default type input method (entire keyboard)
    self.textView.scrollEnabled = YES;

    // this will cause automatic vertical resize when the table is resized
    self.textView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
    // note: for UITextView, if you don't like autocompletion while typing use:
    // myTextView.autocorrectionType = UITextAutocorrectionTypeNo;
    [self.view addSubview: self.textView];  
}

在viewdidload中调用方法