Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import "HMXNewPersonelStep1ViewController.h"
- @implementation HMXNewPersonelStep1ViewController
- - (id)initWithNibName:(NSString *)nibNameOrNil
- bundle:(NSBundle *)nibBundleOrNil{
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
- }
- return self;
- }
- - (void)viewDidLoad{
- [super viewDidLoad];
- [self registerForKeyboardNotifications];
- self.gestureRecognizer =
- [[UITapGestureRecognizer alloc]
- initWithTarget:self
- action:@selector(handleSingleTap:)];
- [self.scrollView
- addGestureRecognizer:self.gestureRecognizer];
- }
- - (void)didReceiveMemoryWarning{
- [super didReceiveMemoryWarning];
- }
- -(void) windowClosed:(NSNotification*)notification {
- [self.scrollView removeGestureRecognizer:self.gestureRecognizer];
- }
- - (void)registerForKeyboardNotifications {
- [[NSNotificationCenter defaultCenter]
- addObserver:self
- selector:@selector(keyboardDidShow:)
- name:UIKeyboardDidShowNotification object:nil];
- [[NSNotificationCenter defaultCenter]
- addObserver:self
- selector:@selector(keyboardWillHide:)
- name:UIKeyboardWillHideNotification object:nil];
- }
- - (void)keyboardDidShow:(NSNotification*)aNotification {
- NSDictionary* info = [aNotification userInfo];
- _kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
- }
- - (void)keyboardWillHide:(NSNotification*)aNotification {
- UIEdgeInsets contentInsets = UIEdgeInsetsZero;
- _scrollView.contentInset = contentInsets;
- _scrollView.scrollIndicatorInsets = contentInsets;
- }
- - (void)adjustView{
- UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0, 0.0, _kbSize.height, 0.0);
- _scrollView.contentInset = contentInsets;
- _scrollView.scrollIndicatorInsets = contentInsets;
- CGRect aRect = self.view.frame;
- aRect.size.height -= _kbSize.height;
- CGPoint aPoint =
- CGPointMake(0, _activeField.frame.origin.y+100);
- if (!CGRectContainsPoint(aRect, aPoint) ) {
- _oldContentOffset = [_scrollView contentOffset];
- CGPoint scrollPoint =
- CGPointMake(0.0, _activeField.frame.origin.y-_kbSize.height+100);
- [_scrollView setContentOffset:scrollPoint animated:YES];
- NSLog(@"adjusted...", nil);
- }
- }
- - (IBAction)textFieldEditingDidBegin:(id)sender {
- _activeField = (UITextField*)sender;
- [self adjustView];
- }
- - (IBAction)textFieldEditingDidEnd:(id)sender {
- _activeField = nil;
- }
- - (void)handleSingleTap:(UITapGestureRecognizer*)sender {
- if (sender.state == UIGestureRecognizerStateEnded){
- [self backgroundClicked:self];
- }
- }
- - (IBAction)backgroundClicked:(id)sender {
- NSLog(@"click!", nil);
- [self.view endEditing:YES];
- }
- - (IBAction)backButtonClicked:(id)sender {
- [self.navigationController popViewControllerAnimated:YES];
- }
- - (IBAction)nextButtonClicked:(id)sender {
- [self performSegueWithIdentifier:@"next" sender:self];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement