how can I dismiss keyboard when I will just touch anywhere except UITextField?

后端 未结 10 2083
独厮守ぢ
独厮守ぢ 2021-02-19 11:12

Hello I have two UITextFields in my application, and want to dismiss the keyboard when I just touch anywhere except the UITextFields how can I do this?

10条回答
  •  Happy的楠姐
    2021-02-19 11:45

    You need to define the action for your button click this way
    
    [infoButton addTarget:self action:@selector(backButtonClicked) forControlEvents:UIControlEventTouchUpInside];
    
    
    And implement the click method ,as for example i have provided the animation on button click method.
    -(void)backButtonClicked
    {
    
        [UIView beginAnimations:@"animation" context:nil];
        [UIView setAnimationDuration:1.5];
        [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO]; 
        [self.navigationController popViewControllerAnimated:YES]; 
        [UIView commitAnimations];
    
    }
    
    
    Hope this will help you ,the action is without using IB.Its all done through coding
    

提交回复
热议问题