Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 05-18-2010, 06:58 AM   #1 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 38
boyax is on a distinguished road
Default UIScrollView no response after clicking done butotn

The application consists of the scrollview with a lots of textfield.
Basically, I could scroll the scroll view..

I'm having problem when I clicked on the textfield for input, then, clicking done of the keyboard, keyboard hides..
but the view or the scroll view is not responding or freezes... I can't scroll..

Pls help me.

.m file:
Code:
#define SCROLLVIEW_CONTENT_HEIGHT 870
#define SCROLLVIEW_CONTENT_WIDTH  320

- (void)viewWillAppear:(BOOL)animated 
{
   [super viewWillAppear:animated];     
   [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name: UIKeyboardDidShowNotification object:nil];

   [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name: UIKeyboardDidHideNotification object:nil];
     
   m_scrollView.contentSize = CGSizeMake(SCROLLVIEW_CONTENT_WIDTH, SCROLLVIEW_CONTENT_HEIGHT);     
   displayKeyboard = NO;
}

- (void)viewWillDisappear:(BOOL)animated 
{
   [[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void)keyboardDidShow: (NSNotification *)notif 
{
   if (displayKeyboard) {
     return;
   }

   NSDictionary* info = [notif userInfo];
   NSValue* aValue = [info objectForKey:UIKeyboardBoundsUserInfoKey];
   CGSize keyboardSize = [aValue CGRectValue].size;
   offset = m_scrollView.contentOffset;

   CGRect viewFrame = m_scrollView.frame;
   viewFrame.size.height -= keyboardSize.height;

   m_scrollView.frame = viewFrame;

   CGRect textFieldRect = [m_activeField frame];
   textFieldRect.origin.y += 10;

   [m_scrollView scrollRectToVisible: textFieldRect animated:YES];
   displayKeyboard = YES;
}

- (void) keyboardDidHide: (NSNotification *)notif 
{
   if (!displayKeyboard) {
     return; 
   }

   m_scrollView.frame = CGRectMake(0, 0, SCROLLVIEW_CONTENT_WIDTH, SCROLLVIEW_CONTENT_HEIGHT);     
   m_scrollView.contentOffset = offset;
   displayKeyboard = NO;     
}

#pragma mark * Textfield Delegate Methods
- (void)textFieldDidEndEditing:(UITextField *)textField
{
   if (textField == m_userNameField) 
   {
      //check username if exists
   }
   else if(textField == m_emailPrimaryField || textField == m_emailSecondaryField)  
   {
       //check input for email formatting
   }
}

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
   BOOL bReturn = YES;

   if (textField == m_userNameField || textField == m_firstNameField || textField == m_lastNameField) 
   {
      //text entry filter only alphanum inputs
   }     

   return bReturn;
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
   [textField resignFirstResponder];
   return YES;

}

-(BOOL) textFieldShouldBeginEditing:(UITextField*)textField 
{
   m_activeField = textField;
   return YES;
}
.h file
Code:
@interface NewUserViewController : UIViewController <UIScrollViewDelegate, UITextFieldDelegate>
{
   BOOL               displayKeyboard;
   CGPoint          offset;
   UITextField          *m_activeField;
   ....
}
boyax is offline   Reply With Quote
Reply

Bookmarks

Tags
uiscrollview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 308
9 members and 299 guests
Abidullah, ajay123123, Fstuff, guusleijsten, HemiMG, newDev, pkIDSF, Sami Gh, Steven.C
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,648
Threads: 94,113
Posts: 402,877
Top Poster: BrianSlick (7,990)
Welcome to our newest member, brandon6031
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 07:48 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0