ios9 – 完成按钮在数字键盘iOS 9问题中不可见

ios9 – 完成按钮在数字键盘iOS 9问题中不可见,第1张

概述这段代码在ios 6,7,8中工作,但是所有方法都在ios 9中调用,但它不可见.在数字垫上.这是我的代码. #import "ViewController.h"#define TAG_BUTTON_DONE 67125@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad 这段代码在ios 6,7,8中工作,但是所有方法都在ios 9中调用,但它不可见.在数字垫上.这是我的代码.

#import "VIEwController.h"#define TAG_button_DONE 67125@interface VIEwController ()@end@implementation VIEwController- (voID)vIEwDIDLoad {    [super vIEwDIDLoad];    [[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(keyboardDIDShow:) name:UIKeyboardDIDShowNotification object:nil];    // Do any additional setup after loading the vIEw,typically from a nib.}- (voID)dIDReceiveMemoryWarning {    [super dIDReceiveMemoryWarning];    // dispose of any resources that can be recreated.}- (voID)keyboardDIDShow:(NSNotification *)note {    [self addbuttonToKeyboard];}- (voID)addbuttonToKeyboard{    //NSLog(@"addbuttonToKeyboard");    //jenish    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {        // create custom button        UIbutton *donebutton = [UIbutton buttonWithType:UIbuttonTypeCustom];        donebutton.frame = CGRectMake(0,163,106,53);        donebutton.adjustsImageWhenHighlighted = NO;        [donebutton setTag:TAG_button_DONE];        //[donebutton setimage:[UIImage imagenamed:@"doneup.png"] forState:UIControlStatenormal];        //[donebutton setimage:[UIImage imagenamed:@"donedown.png"] forState:UIControlStateHighlighted];        [donebutton setTitle:@"Done" forState:UIControlStatenormal];        [donebutton setTintcolor:[UIcolor blackcolor]];        [donebutton addTarget:self action:@selector(donebutton:) forControlEvents:UIControlEventtouchUpInsIDe];        // locate keyboard vIEw        int windowCount = (int)[[[UIApplication sharedApplication] windows] count];        if (windowCount < 2) {            return;        }        UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];        UIVIEw* keyboard;        for(int i=0; i<[tempWindow.subvIEws count]; i++) {            keyboard = [tempWindow.subvIEws objectAtIndex:i];            // keyboard found,add the button            if([[keyboard description] hasPrefix:@"<UIPeripheralHost"] == YES){                [keyboard addSubvIEw:donebutton];            }            else if([[keyboard description] hasPrefix:@"<UIinputSetContainerVIEw"] == YES){                for(int j = 0 ; j < [keyboard.subvIEws count] ; j++) {                    UIVIEw* hostkeyboard = [keyboard.subvIEws objectAtIndex:j];                    if([[hostkeyboard description] hasPrefix:@"<UIinputSetHost"] == YES){                        [hostkeyboard addSubvIEw:donebutton ];                        [hostkeyboard bringSubvIEwToFront:donebutton];                    }                }            }            else            {                dispatch_async(dispatch_get_main_queue(),^{                    [keyboard addSubvIEw:donebutton];                });            }        }    }}- (voID)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {    UItouch * touch = [touches anyObject];    if(touch.phase == UItouchPhaseBegan) {        [self.tf resignFirstResponder];    }}@end

然后你需要去背景并且在前面它会显示几秒钟而不是它会隐藏.请帮我.
谢谢

解决方法 更改

UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];

至 :

UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] lastObject];
总结

以上是内存溢出为你收集整理的ios9 – 完成按钮数字键盘iOS 9问题中不可见全部内容,希望文章能够帮你解决ios9 – 完成按钮在数字键盘iOS 9问题中不可见所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1028427.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存