2015-10-10 287 views
0

我有一個UITextField的VC。這就是我的代碼:UITextField,隱藏鍵盤,TopBar仍然存在

.H

@interface GameOverViewController : UIViewController <UITextFieldDelegate> { 
} 

.M

@implementation UITextField (DisableCopyPaste) 

-(BOOL)canPerformAction:(SEL)action withSender:(id)sender 
{ 

return NO; 
return [super canPerformAction:action withSender:sender]; 
} 

@end 

@implementation GameOverViewController 

NSString *text1; 



text1 = @""; 

UIView* testView = [[UIView alloc] init]; 
_nameField.inputView = testView; 
[_nameField becomeFirstResponder]; 
_nameField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter; 

這是隱藏鍵盤:

UIView* testView = [[UIView alloc] init]; 
_nameField.inputView = testView; 

但現在仍然有鍵盤的頂欄在我看來:

bottombar

如果我拿出這個代碼兩行,將出現全鍵盤:

enter image description here

我不能讓它牆根。我不想要這個酒吧。

如果我禁用UITextField,酒吧就沒了。

回答

0

找到了解決辦法:

在iOS版9

有一個UITextInoutAssistantItem,這裏是我爲這個酒吧解決方案:

if ([self respondsToSelector:@selector(inputAssistantItem)]) { 

UITextInputAssistantItem *item = [self inputAssistantItem]; 
item.leadingBarButtonGroups = @[]; 
item.trailingBarButtonGroups = @[]; 
}