2017-10-11 51 views
0

我在我的登錄視圖控制器中成功導入了IQKeyboardManger。從那以後,我加入這個代碼IQKeyboardManager不適用於視圖控制器中的文本字段?

//在viewDidLoad中

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view. 

    //IQKeyboardManager 
    [[IQKeyboardManager sharedManager] setEnable:YES]; 

    [[IQKeyboardManager sharedManager] setKeyboardDistanceFromTextField:100]; 

    [[IQKeyboardManager sharedManager] setEnableAutoToolbar:YES]; 

    [[IQKeyboardManager sharedManager] setShouldShowTextFieldPlaceholder:YES]; 

    [self.ad.window makeKeyAndVisible]; 

} 

但它不是在iOS的工作11.0

屏幕1

enter image description here

屏幕2

enter image description here

我在應用程序委託添加的代碼

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
self.mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil]; 

//Identify launching status(Is first time or not) 
//If it is first time go to login page 
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"HasLaunchedOnce"]) { 
    self.lpvc = [self.mainStoryboard instantiateViewControllerWithIdentifier:@"LPVC"]; 
    self.window.rootViewController = self.lpvc; 
    NSLog(@"Launched first time"); 
    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"HasLaunchedOnce"]; 
    [[NSUserDefaults standardUserDefaults] synchronize]; 

    //IQKeyboarbManager 
    [[IQKeyboardManager sharedManager] setEnable:YES]; 
//  [[IQKeyboardManager sharedManager] setKeyboardDistanceFromTextField:100]; 
    [[IQKeyboardManager sharedManager] setEnableAutoToolbar:YES]; 
    [[IQKeyboardManager sharedManager] setShouldShowTextFieldPlaceholder:YES]; 
} else { 
    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"loggedin"]) { 
    self.rvc = [self.mainStoryboard instantiateViewControllerWithIdentifier:@"RVC"]; 
    self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:self.rvc]; 
     NSLog(@"Already launched"); 
     [self getDataFromServer]; 
//   [self.rvc checkAppVersion]; 
    } 
} 

[self.window makeKeyAndVisible]; 

return yes; 
+0

有何利用這一[self.ad.window makeKeyAndVisible] –

+0

究竟什麼不行?你在期待什麼? – Glenn

+0

@ Anbu.Karthik我不完全一樣,我從這個鏈接複製..... http://www.binpress.com/app/iqkeyboardmanager/1869 – iOS

回答

0

複製該代碼AppDelegate

AppDelegate.m

#import "AppDelegate.h" 
#import "IQKeyboardManager.h" 

@implementation AppDelegate 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
//ONE LINE OF CODE. 
//Enabling keyboard manager(Use this line to enable managing distance between keyboard & textField/textView). 
[[IQKeyboardManager sharedManager] setEnable:YES]; 

//(Optional)Set Distance between keyboard & textField, Default is 10. 
//[[IQKeyboardManager sharedManager] setKeyboardDistanceFromTextField:15]; 

//(Optional)Enable autoToolbar behaviour. If It is set to NO. You have to manually create UIToolbar for keyboard. Default is NO. 
[[IQKeyboardManager sharedManager] setEnableAutoToolbar:YES]; 

//(Optional)Setting toolbar behaviour to IQAutoToolbarBySubviews to manage previous/next according to UITextField's hierarchy in it's SuperView. Set it to IQAutoToolbarByTag to manage previous/next according to UITextField's tag property in increasing order. Default is `IQAutoToolbarBySubviews`. 
//[[IQKeyboardManager sharedManager] setToolbarManageBehaviour:IQAutoToolbarBySubviews]; 

//(Optional)Resign textField if touched outside of UITextField/UITextView. Default is NO. 
//[[IQKeyboardManager sharedManager] setShouldResignOnTouchOutside:YES]; 

//(Optional)Giving permission to modify TextView's frame. Default is NO. 
//[[IQKeyboardManager sharedManager] setCanAdjustTextView:YES]; 

//(Optional)Show TextField placeholder texts on autoToolbar. Default is NO. 
[[IQKeyboardManager sharedManager] setShouldShowTextFieldPlaceholder:YES]; 

[self.window makeKeyAndVisible]; 
return YES; 
} 

,它會正常工作。

注:請確保您有更新到最新版本(5.0.3)

+0

對我沒有用....它不工作 – iOS

+0

是我昨天通過豆莢, – iOS

+0

我在AppDelegate添加代碼是self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen]界限]]; self.mainStoryboard = [UIStoryboard storyboardWithName:@「Main」bundle:nil]; //識別啓動狀態(是否第一次)//如果是第一次進入登錄頁 – iOS

相關問題