Dismissing the keyboard in a UIScrollView

后端 未结 12 2285
醉话见心
醉话见心 2020-11-30 20:18

Alright, I have a couple of UITextFields and UITextViews inside a UIScrollView, and I\'d like to set the keyboard to disappear wheneve

12条回答
  •  醉梦人生
    2020-11-30 20:48

    Try this scroll view delegate method -

    link delegate in IB to scroll view and then cop this code (modify as per your need).

    - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
    {         
    //sample code    
        [challengeABallotComponent.voterNameTextField resignFirstResponder];
        [challengeABallotComponent.ballotNumberTextField resignFirstResponder];
        [locationInformation.pollingLocation resignFirstResponder];
    }
    

    This should work. You can try other delegate methods too like

       -(void)scrollViewDidScroll: (UIScrollView *)scrollView 
    {
    //do your stuff
    }
    

提交回复
热议问题