iOS模拟器中的UITextView输入游标问题

时间:2014-12-16 07:54:24

标签: ios objective-c uitextview subview

我正在尝试为我的iOS应用程序创建动态UITextViewController。所以从我的ApplicationViewController我试图获取TextView。

Textview正常运行但我的UITextView的输入光标下降了。如何从顶部获取蓝色输入光标?

enter image description here

TextViewController.m

+(UITextField *)prepareUITextView
{
    UITextView *uiTextView= [[UITextView alloc] initWithFrame:CGRectMake(
                                                          10, 80, 300, 100)];
    uiTextView.layer.borderWidth = 1.0;
    uiTextView.layer.cornerRadius = 8;
    uiTextView.font = [UIFont systemFontOfSize:15];
    uiTextView.autocorrectionType = UITextAutocorrectionTypeNo;
    uiTextView.keyboardType = UIKeyboardTypeDefault;
    uiTextView.returnKeyType = UIReturnKeyDone;
    [uiTextView becomeFirstResponder];
    uiTextView.selectedRange = NSMakeRange(0, 0);
    return uiTextView;
}

ApplicationViewController.m

[self.view addSubview:[TextViewController prepareUITextView]];

1 个答案:

答案 0 :(得分:2)

试试此代码

uiTextView.contentInset = UIEdgeInsetsMake(-7.0,0.0,0,0.0);

按照您想要的方式调整Top值。这将解决您的问题。