user3098173
user3098173

Reputation: 133

White line on the bottom on ios 7 with UITextField

I have text field, i need to show the cursor and hide the keyboard. It looks ok in the IOS 6 and IOS 5. But in IOS 7 i can see small white line on the bottom.

My code is

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

Anyone having any thought how to fix this?

Upvotes: 2

Views: 790

Answers (1)

sateesh
sateesh

Reputation: 497

I think this is due to the keyboard view, whose having the height as 1. So if you change the line

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

to

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

it will work.

Upvotes: 3

Related Questions