【问题标题】:White line on the bottom on ios 7 with UITextFieldios 7底部的白线与UITextField
【发布时间】:2014-01-06 09:12:44
【问题描述】:

我有文本字段,我需要显示光标并隐藏键盘。在 IOS 6 和 IOS 5 中看起来不错。但在 IOS 7 中我可以看到底部的小白线。

我的代码是

UIScrollView *scrollview = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)];
[scrollview setDelegate:self];
[self.view addSubview:scrollview];
[self.view bringSubviewToFront:scrollview];
[scrollview setBackgroundColor:[UIColor blackColor]];

scrollview.contentSize = CGSizeMake(768, 1024);


UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(10, 10, 500, 100)];
textField.borderStyle = UITextBorderStyleRoundedRect;
textField.autocorrectionType = UITextAutocorrectionTypeNo;
textField.keyboardType = UIKeyboardTypeDefault;
textField.returnKeyType = UIReturnKeyDone;
textField.clearButtonMode = UITextFieldViewModeWhileEditing;
textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
textField.returnKeyType = UIReturnKeyDone;
[textField setUserInteractionEnabled:YES];
[textField setEnabled:YES];
[scrollview addSubview:textField];

// Here I need to show the cursor without showing keyboard
UIView* dummyView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, 1)];
((UITextField*)textField).inputView = dummyView;
[((UITextField*)textField) becomeFirstResponder];

有人知道如何解决这个问题吗?

【问题讨论】:

    标签: ios7 uitextfield


    【解决方案1】:

    我认为这是由于键盘视图的高度为 1。 所以如果你换行

    UIView* dummyView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, 1)]; 
    

    UIView* dummyView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
    

    它会起作用的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-10-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多