Friday, November 7, 2014

IOS 7+ Objective-C move up the text boxes when keyboard appears




Hi Now I am doing Objective-C.So I will be writing notes mostly about objective c.This is not meant for teaching you.It is just notes .

The problem we probably face is  buttons are under the keyboard when the keyboard appears.



The result that we want is like this.



So here is the solution for IOS 7 and 8.
First I put all two text boxes and two buttons in UIView.And I am gonna use auto layout top space to top layout guide.  

I will create layout rule as property in h file and connect with storyboard.



Here is the code.

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *verticalspace;


@end


And in .m file we create login box property as customView. 

#import "ViewController.h"

@interface ViewController ()

@property (strong, nonatomic) IBOutlet UIView *customView;
@end

@implementation ViewController


- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardDidShowNotification object:nil];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillBeHidden:) name:UIKeyboardWillHideNotification object:nil];
    
}

- (void)keyboardWillShow:(NSNotification*)aNotification {
       [UIView animateWithDuration:0.25 animations:^
     {
         if (self.customView.frame.origin.y <=120) {
         }
         else{
         
             self.verticalspace.constant -= 100;
             [self.view layoutIfNeeded];
         }
         
     }completion:^(BOOL finished)
     {
         
     }];
}

- (void)keyboardWillBeHidden:(NSNotification*)aNotification {
    [UIView animateWithDuration:0.25 animations:^
     {
         CGRect newFrame = [self.customView frame];
         newFrame.origin.y -= 50; // tweak here to adjust the moving position
         [self.customView setFrame:newFrame];
         
     }completion:^(BOOL finished)
     {
         
     }];
    
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    [self.view endEditing:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end




Monday, June 2, 2014

Using Yeoman for front-end web developers


Using Yeoman  for modern webapps


There are three main components in yeoman.
1.Yo      http://yeoman.io/
2.Grunt  http://gruntjs.com/
3.Bower. http://bower.io/

Installation

1.open your command prompt .and run.This command line will install all the tools globally.
           =>  npm install -g yo
2.install web app generator
           =>  npm install -g generator-webapp
  if you want to install AngularJS generator you can run
            =>  npm install -g generator-angular  yo webapp
  it will ask to choose some options.Example 
            bootstrap
            Sass
            Modernizr 
 after you choose ,it will automatically create skeleton web app project
3.to install dependency for the project from bower ,please run
          =>  bower install underscore
4.build the application for the deployment
          =>  grunt
5.so if you go and see in your project folder , you will see something like this.

6.To check your web app from browser, run
          =>grunt serve
 it will open browser and you will see something like this.

7.Now you can start to develop your own web project