2014-01-06 96 views
2

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

我的代码是具有任何想如何解决这个问题

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]; 

enter image description here

有人吗?

回答

3

我想,如果你改变了行

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

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

它会工作,这是由于键盘的视图,它具有高度为1 所以其。

+0

它的工作原理。非常感谢sateesh – user3098173

+0

你欢迎。如果它有效,请接受这个答案。 – sateesh