我的问题是当我解雇,我得到两个通知键盘隐藏和再次显示.
有人可以告诉我如何防止这个问题?它只发生在iOS 7中,并使用SDK 7构建
更新一些代码:
在vIEwDIDLoad中,我初始化一个按钮,当触摸按钮, *** 作表将被显示.
- (voID)vIEwDIDLoad{ [super vIEwDIDLoad]; UIbutton* button = [UIbutton buttonWithType:UIbuttonTypeRoundedRect]; button.frame = CGRectMake(10,50,100,30); [button setTitle:@"Open menu" forState:UIControlStatenormal]; [button addTarget:self action:@selector(buttontouched) forControlEvents:UIControlEventtouchUpInsIDe]; [self.vIEw addSubvIEw:button]; UITextVIEw* textVIEw = [[UITextVIEw alloc] initWithFrame:CGRectMake(0,40)]; [self.vIEw addSubvIEw:textVIEw]; [textVIEw becomeFirstResponder]; [[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(keyboarDWillHIDe:) name:UIKeyboarDWillHIDeNotification object:nil]; [[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(keyboarDWillShow:) name:UIKeyboarDWillShowNotification object:nil];}- (voID)searchbarCancelbuttonClicked:(UISearchbar *) searchbar{ [searchbar resignFirstResponder];}- (voID) buttontouched{ UIActionSheet* actionSheet = [[UIActionSheet alloc] initWithTitle:@"Action sheet" delegate:self cancelbuttonTitle:@"Cancel" destructivebuttonTitle:@"Destructive" otherbuttonTitles:@"Hello",nil]; [actionSheet showInVIEw:self.vIEw];}- (voID)keyboarDWillShow:(NSNotification*)notification{ NSLog(@"keyboarDWillShow");}- (voID)keyboarDWillHIDe:(NSNotification*)notification{ NSLog(@"keyboarDWillHIDe");}
我运行应用程序,键盘会显示,我触摸按钮,动作表显示.我通过触摸其上的任何按钮关闭 *** 作表,并记录打印:
解决方法 有一个非常简单的解决方案.应该在控制器的.m文件中添加私人本地类别keyboarDWillShow
keyboarDWillHIDe
keyboarDWillShow
@interface UIActionSheet (NonFirstResponder)@end@implementation UIActionSheet (NonFirstResponder)- (BOol)canBecomeFirstResponder{ return NO;}@end
只有一个副作用.您的texFIEld / textVIEw在 *** 作列表中保留焦点.但这不是我想的一大麻烦.
也可以以相同的方式对UIActionSheet进行子类化.
总结以上是内存溢出为你收集整理的UIActionSheet在iOS 7,SDK 7中关闭后,键盘隐藏并再次显示全部内容,希望文章能够帮你解决UIActionSheet在iOS 7,SDK 7中关闭后,键盘隐藏并再次显示所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)