ios - UIScrollView में UITextFied स्क्रॉल करने के बाद सक्षम नहीं है




uiview uitextfield (2)

आपका पाठ फ़ील्ड पर्यवेक्षित सीमा से बाहर है आपको दृश्य का आकार बदलना चाहिए ताकि सभी पाठ फ़ील्ड सीमा के भीतर हो जाए।

मैं एक UIScrollView में एक ViewController जोड़ा गया, और उस UIScrollView तहत जोड़ा गया UIView

मैंने उस UIView में कुल संख्या 10 UITextFields जोड़े, स्क्रोलिंग कार्य ठीक है

सिम्युलेटर / आईफ़ोन में ऐप चलते हुए, प्रथम 6 UITextFields वर्किंग [टेप को जवाब देना] स्क्रीन पर बिना स्क्रॉल किए दिखाए जाते हैं, शेष 4 UITextFields काम नहीं कर रहे हैं [छूने का जवाब नहीं], जो स्क्रॉलिंग के बाद दिखाया जाएगा

कृपया कोई भी इस मुद्दे को हल करने के लिए मुझे मार्गदर्शन कर सकता है?

धन्यवाद

अद्यतनः मैंने इसे ViewController में उपयोग किया था

override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        scrollView.contentSize = CGSize(width: self.view.frame.size.width, height: 1070);
    }

ViewControllerStructure निम्नानुसार है


इस कोड की कोशिश करो यह मेरे लिए काम करता है

एच में

{
    IBOutlet UIScrollView *scrView;
        UITextField *currentTextField;
        BOOL keyboardIsShown;
}
-(IBAction)backButtonClicked:(id)sender;

और .m फ़ाइल में

//---size of keyboard---
CGRect keyboardBounds;  
//---size of application screen---
CGRect applicationFrame;
//---original size of ScrollView---
CGSize scrollViewOriginalSize;


- (void)moveScrollView:(UIView *) theView {  
    //---get the y-coord of the view---
    CGFloat viewCenterY = theView.center.y;  

    //---calculate how much free space is left---
    CGFloat freeSpaceHeight = applicationFrame.size.height - keyboardBounds.size.height;      

    CGFloat scrollAmount = viewCenterY - freeSpaceHeight / 2.5;  

    if (scrollAmount < 0)  scrollAmount = 0;  

    //---set the new scrollView contentSize---
    scrView.contentSize = CGSizeMake(
                                        applicationFrame.size.width, 
                                        applicationFrame.size.height + keyboardBounds.size.height);  

    //---scroll the ScrollView---
    [scrView setContentOffset:CGPointMake(0, scrollAmount) animated:YES];  
}

//---when a TextField view begins editing---
-  (void)textFieldDidBeginEditing:(UITextField *)textFieldView {  
    [self moveScrollView:textFieldView];
}  

//---when a TextField view is done editing---
- (void)textFieldDidEndEditing:(UITextField *) textFieldView {  
    //[scrollView setContentOffset:CGPointMake(0, -(dis * 2.0)) animated:YES];  
    [UIView beginAnimations:@"back to original size" context:nil];
    scrView.contentSize = scrollViewOriginalSize;
    [UIView commitAnimations];

}

//---when the keyboard appears---
- (void)keyboardWillShow:(NSNotification *) notification
{
    //---gets the size of the keyboard---
    NSDictionary *userInfo = [notification userInfo];  
    NSValue *keyboardValue = [userInfo objectForKey:UIKeyboardBoundsUserInfoKey];  
    [keyboardValue getValue:&keyboardBounds];   
}

- (void)keyboardWillHide:(NSNotification *) notification
{

}
-(BOOL)textFieldShouldReturn:(UITextField *)textFieldView
{
    [textFieldView resignFirstResponder];

    return NO;

}

-(void)viewWillAppear:(BOOL)animated
{   
    //---registers the notifications for keyboard---
    [[NSNotificationCenter defaultCenter] 
     addObserver:self 
     selector:@selector(keyboardWillShow:) 
     name:UIKeyboardWillShowNotification 
     object:self.view.window]; 

    [[NSNotificationCenter defaultCenter]
     addObserver:self
     selector:@selector(keyboardWillHide:)
     name:UIKeyboardWillHideNotification
     object:nil];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [[NSNotificationCenter defaultCenter] 
     removeObserver:self 
     name:UIKeyboardWillShowNotification 
     object:nil];

    [[NSNotificationCenter defaultCenter] 
     removeObserver:self 
     name:UIKeyboardWillHideNotification 
     object:nil];
}

- (void)viewDidLoad 
   {        
        txt1.keyboardAppearance = UIKeyboardAppearanceAlert;
        txt2.keyboardAppearance = UIKeyboardAppearanceAlert;
        txt3.keyboardAppearance = UIKeyboardAppearanceAlert;
        txt4.keyboardAppearance = UIKeyboardAppearanceAlert;
        txt5.keyboardAppearance = UIKeyboardAppearanceAlert;
        txt6.keyboardAppearance = UIKeyboardAppearanceAlert;
        txt7.keyboardAppearance = UIKeyboardAppearanceAlert;
        txt8.keyboardAppearance = UIKeyboardAppearanceAlert;
        txt9.keyboardAppearance = UIKeyboardAppearanceAlert;
        txt10.keyboardAppearance = UIKeyboardAppearanceAlert;


        scrollViewOriginalSize = scrView.contentSize;
        applicationFrame = [[UIScreen mainScreen] applicationFrame];    
        [super viewDidLoad];
}


- (void)dealloc {
    [scrView release];
    [super dealloc];
}