IOS_DatePicker_PickerView_SegmentControl_키보드 처리

H:/0712/01_UIController_MJViewController.m
//  MJViewController.m
//  01-    
//  Created by apple on 13-7-12.
//  Copyright (c) 2013  itcast. All rights reserved.
/*---------------------------------------
UIControl   UIView
    UIControl   ,      .
addTarget  
--------------------------------------
  ,        :
   ViewController
   |--View
   
Xcode       
Xcode        
viewControll  FirstResponder   
*/
#import "MJViewController.h"
@interface MJViewController ()
@end
@implementation MJViewController
- (void)viewDidLoad
{
    [super viewDidLoad];
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeContactAdd];
    btn.center = CGPointMake(100, 100);
    [self.view addSubview:btn];
}
@end

H:/0712/02_코드 1 줄 추가 1 줄 삭제MJViewController.h
//
//  MJViewController.h
//  02-       -    
//
//  Created by apple on 13-7-12.
//  Copyright (c) 2013  itcast. All rights reserved.
/*
-----------------------------------
       :

-----------------------------------
1.      
      :Destination + Add to targets(2     )
2.  UI  
3.        
4.        

---------------------------------
      :
1.      UIView
2.      ,       UIView  
*/

/*
 1.   ,          
 2.   
 */

#import <UIKit/UIKit.h>

@interface MJViewController : UIViewController
// UIBarButtonItem       storyBoard    enabled     
@property (nonatomic, weak) IBOutlet UIBarButtonItem *removeItem;

//       ,    
- (IBAction)addRow;

//       ,    
- (IBAction)removeRow;

@end

H:/0712/02_코드 1 줄 추가 1 줄 삭제MJViewController.m
//  MJViewController.m
//  02-       -    
//  Created by apple on 13-7-12.
//  Copyright (c) 2013  itcast. All rights reserved.
/*
-----------------------------------
       :

-----------------------------------
1.      
      :Destination + Add to targets(2     )
2.  UI  
3.        
4.        

---------------------------------
      :
1.      UIView
2.      ,       UIView  
*/
#import "MJViewController.h"
//   :  
#define kRowHeight 70
@interface MJViewController ()
@end
@implementation MJViewController
#pragma mark       ,    
- (IBAction)addRow
{
    // 0.            ,    y     
    UIView *lastChild = [self.view.subviews lastObject];
    // 1.      (UIView)
    UIView *newRow = [[UIView alloc] init];
    //       view   ,   
    CGFloat viewWidth = self.view.frame.size.width;
    //        Y  ==         Y +            + 1
    CGFloat newRowY = lastChild.frame.origin.y + lastChild.frame.size.height + 1;
    //           
    newRow.frame = CGRectMake(0, newRowY, viewWidth, kRowHeight);
    //       
    newRow.backgroundColor = [UIColor grayColor];
    // 2.           view 
    [self.view addSubview:newRow];
    // 3.   item  (      ),   storyBoard      enabled
    self.removeItem.enabled = YES;
    // 4.       (newRow)       ,      
    // 4.1       
    UILabel *nameView = [[UILabel alloc] init];
    nameView.text = @"3213124324";
    //   center(          RowView    )
    nameView.center = CGPointMake(viewWidth * 0.5, kRowHeight * 0.5);
    //   bounds(    ,     )
    nameView.bounds = CGRectMake(0, 0, 200, 40);
    //   Lable       
    nameView.textAlignment = NSTextAlignmentCenter;
    //   Lable     
    nameView.backgroundColor = [UIColor clearColor];
    [newRow addSubview:nameView];
    // 4.2            (newRow)
    UIButton *iconView = [UIButton buttonWithType:UIButtonTypeCustom];
    //   center
    iconView.center = CGPointMake(40, kRowHeight * 0.5);
    //     
    iconView.bounds = CGRectMake(0, 0, 44, 44);
    //        
    // arc4random() //          
    int index = arc4random_uniform(8); //   [0, 8]   
    NSString *imageName = [NSString stringWithFormat:@"%d.png", index];
    UIImage *image = [UIImage imageNamed:imageName];
    //          
    [iconView setBackgroundImage:image forState:UIControlStateNormal];
    [newRow addSubview:iconView];
}
#pragma mark       ,    
- (IBAction)removeRow
{
    // 1.         
    UIView *lastChild = [self.view.subviews lastObject];
    // 2.         
    [lastChild removeFromSuperview];
    // 3.    item    ,         
    /*
    if (self.view.subviews.count == 1) {
        self.removeItem.enabled = NO;
    } else {
        self.removeItem.enabled = YES;
    }*/
    //           ,    item   
    //           ,    item  
    self.removeItem.enabled = self.view.subviews.count > 1;
}
@end

H:/0712/03_코드 1 줄 추가 1 줄 삭제 2MJViewController.h
//
//  MJViewController.h
//  02-       -    
//
//  Created by apple on 13-7-12.
//  Copyright (c) 2013  itcast. All rights reserved.
//

/*
 1.   (       )
 2.   
 3.        
 4.          
 */

#import <UIKit/UIKit.h>

@interface MJViewController : UIViewController
// UIBarButtonItem       storyBoard    enabled     
@property (nonatomic, weak) IBOutlet UIBarButtonItem *removeItem;

//       ,    
- (IBAction)addRow;

//       ,    
- (IBAction)removeRow;

@end

H:/0712/03_코드 1 줄 추가 1 줄 삭제 2MJViewController.m
//  MJViewController.m
//  02-       -    
//  Created by apple on 13-7-12.
//  Copyright (c) 2013  itcast. All rights reserved.
//   :  
#define kRowHeight 70
#define kNameTag 5
#import "MJViewController.h"
@interface MJViewController ()
@end
@implementation MJViewController
#pragma mark       ,    
- (IBAction)addRow
{
    // 0.            ,    y     
    UIView *lastChild = [self.view.subviews lastObject];
    // 1.      (UIView)
    UIView *newRow = [[UIView alloc] init];
    //     view   ,   
    CGFloat viewWidth = self.view.frame.size.width;
    //        Y  ==         Y +            + 1
    CGFloat newRowY = lastChild.frame.origin.y + lastChild.frame.size.height + 1;
    //        
    newRow.frame = CGRectMake(0, newRowY, viewWidth, kRowHeight);
    //       
    newRow.backgroundColor = [UIColor grayColor];
    // 2.           view 
    [self.view addSubview:newRow];
    // 3.   item  ,   storyBoard      enabled
    self.removeItem.enabled = YES;
    // 4.       (newRow)       ,      
    // 4.1       
    UILabel *nameView = [[UILabel alloc] init];
    nameView.text = [NSString stringWithFormat:@"mike---%d", self.view.subviews.count];
    //   center(          RowView    )
    nameView.center = CGPointMake(viewWidth * 0.5, kRowHeight * 0.5);
    //   bounds(    ,     )
    nameView.bounds = CGRectMake(0, 0, 200, 40);
    //   Lable       
    nameView.textAlignment = NSTextAlignmentCenter;
    //   Lable   tag,            ---------------
    nameView.tag = kNameTag;
    //   Lable     
    nameView.backgroundColor = [UIColor clearColor];
    [newRow addSubview:nameView];
    // 4.2            (newRow)
    UIButton *iconView = [UIButton buttonWithType:UIButtonTypeCustom];
    //   center
    iconView.center = CGPointMake(40, kRowHeight * 0.5);
    //     
    iconView.bounds = CGRectMake(0, 0, 44, 44);
    //        
    // arc4random() //          
    int index = arc4random_uniform(8); //   [0, 8]   
    NSString *imageName = [NSString stringWithFormat:@"%d.png", index];
    UIImage *image = [UIImage imageNamed:imageName];
    //          
    [iconView setBackgroundImage:image forState:UIControlStateNormal];
    //         
    [iconView addTarget:self action:@selector(iconClick:)
						forControlEvents:UIControlEventTouchUpInside];
    [newRow addSubview:iconView];
    // 5.     
    // 5.1   newRow   x      
    CGRect frame = newRow.frame;
    frame.origin.x = viewWidth;
    newRow.frame = frame;
    // 5.2   newRow x 0
    frame.origin.x = 0;
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:.3];
    //            
    newRow.frame = frame;
    [UIView commitAnimations];
}
#pragma mark               
- (void)iconClick:(UIButton *)icon
{
    // 1.     
    UIView *superview = icon.superview;
    // 2.      
    UILabel *nameView = (UILabel *)[superview viewWithTag:kNameTag];
    NSLog(@"   ----%@", nameView.text);
}
#pragma mark       ,    
- (IBAction)removeRow
{
    // 1.         
    UIView *lastChild = [self.view.subviews lastObject];
    // 2.  block    
    [UIView animateWithDuration:0.3
    animations:^{ //            
        CGRect frame = lastChild.frame;
        frame.origin.x = self.view.frame.size.width;
        lastChild.frame = frame;
    }
    completion:^(BOOL finished) {
        NSLog(@"      ----");
        [lastChild removeFromSuperview];
		//     item    
        self.removeItem.enabled = self.view.subviews.count > 1;
    }];
    // 2.         
    //[lastChild removeFromSuperview];
    // 3.    item    
    /*
    if (self.view.subviews.count == 1) {
        self.removeItem.enabled = NO;
    } else {
        self.removeItem.enabled = YES;
    }*/
    //           ,    item   
    //           ,    item  
    //self.removeItem.enabled = self.view.subviews.count > 1;
}
@end

H:/0712/04_xib 1 줄 추가 1 줄 삭제MJViewController.h
//  MJViewController.h
//  02-       -  xib
//  Created by apple on 13-7-12.
//  Copyright (c) 2013  itcast. All rights reserved.
#import <UIKit/UIKit.h>
@interface MJViewController : UIViewController
/*
  XIB          ,    :
 1,  XIB  ,FILE'S OWNER   MJViewController
 2,[bundle loadNibNamed:@"row" owner:self options:nil];
	owner              
 3, MJViewController.h          IBAction,
     , XIB        
   ,   XIB     ,   FILE'S OWNER ,           IBAction  
*/

//         ,  AlertView
- (IBAction)iconClick:(UIButton *)sender;


//       ,      
- (IBAction)addRow;
@end

H:/0712/04_xib 1 줄 추가 1 줄 삭제MJViewController.m
//  MJViewController.m
//  02-       -  xib
//  Created by apple on 13-7-12.
//  Copyright (c) 2013  itcast. All rights reserved.
//  xib  == nib  xcode interface builder
/*
  XIB          ,    :
 1,  XIB  ,FILE'S OWNER   MJViewController
 2,[bundle loadNibNamed:@"row" owner:self options:nil];
	owner              
 3, MJViewController.h          IBAction,
     , XIB        
   ,   XIB     ,   FILE'S OWNER ,           IBAction  
*/
#import "MJViewController.h"
@interface MJViewController ()
@end
@implementation MJViewController
- (IBAction)addRow
{
    // 1.  row.xib  
    NSBundle *bundle = [NSBundle mainBundle];
    //  self   File's Owner,  Objects       
    //   NSArray    Objects       
	// owner:   ,       , file's owner      
    NSArray *objs = [bundle loadNibNamed:@"row" owner:self options:nil];
    // 2.   0 ,      
    UIView *newRow = objs[0];
    // 3.    ,   lastChild,       y   
    UIView *lastChild = [self.view.subviews lastObject];
    CGFloat newRowY = lastChild.frame.origin.y + lastChild.frame.size.height + 1;
    CGRect frame = newRow.frame;
    frame.origin = CGPointMake(0, newRowY);
    newRow.frame = frame;
    // 4.           view
    [self.view addSubview:newRow];
    // 5.    
    UILabel *label = (UILabel *)[newRow viewWithTag:10];
    label.text = [NSString stringWithFormat:@"jack-%d", arc4random_uniform(10)];
}
- (IBAction)iconClick:(UIButton *)sender {
    UILabel *label = (UILabel *)[sender.superview viewWithTag:10];
    NSLog(@"%@", label.text);
}
@end

H:/0712/05_UIDatePicker_MJViewController.h
//
//  MJViewController.h
//  05-UIDatePicker
//
//  Created by apple on 13-7-12.
//  Copyright (c) 2013  itcast. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface MJViewController : UIViewController
// Lable  
@property (weak, nonatomic) IBOutlet UILabel *dateLabel;
//    
@property (weak, nonatomic) IBOutlet UITextField *myfield;
//   ,UIDatePicker Value Changed  
- (IBAction)dateChange:(UIDatePicker *)sender;
@end

H:/0712/05_UIDatePicker_MJViewController.m
//  MJViewController.m
//  05-UIDatePicker
//  Created by apple on 13-7-12.
//  Copyright (c) 2013  itcast. All rights reserved.
#import "MJViewController.h"
@interface MJViewController ()
@end
@implementation MJViewController
- (void)viewDidLoad
{
    [super viewDidLoad];    
	// inputView    
    //self.myfield.inputView = [UIButton buttonWithType:UIButtonTypeContactAdd];
    UIDatePicker *picker = [[UIDatePicker alloc] init];
	//      
    picker.datePickerMode = UIDatePickerModeDate;
	//        
    picker.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];
    // inputView    
    self.myfield.inputView = picker;
    // inputAccessoryView          
    self.myfield.inputAccessoryView = [UIButton buttonWithType:UIButtonTypeContactAdd];    
    /*UIDatePicker *picker = nil;
    picker.datePickerMode = UIDatePickerModeDate;
    picker.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];*/    
}
//   UIDatePicker Value Changed  
- (IBAction)dateChange:(UIDatePicker *)sender {
    NSDate *date = sender.date;
	//      NSDateFormatter
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    //       (2010/10/10)
    formatter.dateFormat = @"yyyy/MM/dd";
    //  NSDate  NSString
    NSString *dateStr = [formatter stringFromDate:date];
    self.dateLabel.text = dateStr;
}
@end

H:/0712/06_UIPickerView_MJViewController.h
//
//  MJViewController.h
//  06-UIPickerView
//
//  Created by apple on 13-7-12.
//  Copyright (c) 2013  itcast. All rights reserved.
/*
UIPickView      :
1,             
[pickerView selectedRowInComponent:0];
2,         ,   
  UIPickerView     :  numberOfComponentsInPickerView
  numberOfRowsInComponent,        
3,    :
	   component  row       title
	          :didSelectRow:inComponent:
*/

#import <UIKit/UIKit.h>

@interface MJViewController : UIViewController <UIPickerViewDataSource, UIPickerViewDelegate>

@end

H:/0712/06_UIPickerView_MJViewController.m
//
//  MJViewController.m
//  06-UIPickerView
//
//  Created by apple on 13-7-12.
//  Copyright (c) 2013  itcast. All rights reserved.
/*
UIPickView      :
1,             
[pickerView selectedRowInComponent:0];
2,         ,   
  UIPickerView     :  numberOfComponentsInPickerView
  numberOfRowsInComponent,        
3,    :
	   component  row       title
	          :didSelectRow:inComponent:
*/
#import "MJViewController.h"
@interface MJViewController ()
@property (nonatomic, strong) NSArray *oneCol;
@property (nonatomic, strong) NSArray *twoCol;
@end
@implementation MJViewController
- (void)viewDidLoad
{
    [super viewDidLoad];
	//    1 /    
    self.oneCol = @[@"00", @"01", @"02", @"03"];
	//    2 /    
    self.twoCol = @[@"10", @"11", @"12"];
}
#pragma mark PickerView     :  UIPickerView   
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 2;
}
#pragma mark PickerView     :    component      
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    return component == 0 ? self.oneCol.count : self.twoCol.count;
}

#pragma mark - UIPickerView     
#pragma mark    component  row       title
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row 
								forComponent:(NSInteger)component
{
    if (component == 0)
    { //     0 ,  oneCol    row    
        return self.oneCol[row];
    } else { //     1 ,  twoCol    row    
        return self.twoCol[row];
    }
    //return @"hahahha";
}

#pragma mark           :didSelectRow:inComponent:
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row
							inComponent:(NSInteger)component
{
    //       0 
    if (component == 0)
    {
        //    0  row    
        NSString *left = self.oneCol[row];
        
        //    1        
        int rightRow = [pickerView selectedRowInComponent:1];
        
        //    1  rightRow    
        NSString *right = self.twoCol[rightRow];
        
        NSLog(@"%@ - %@", left, right);
        
    } else { //       1 
        NSString *right = self.twoCol[row];
        
        //    0        
        int leftRow = [pickerView selectedRowInComponent:0];
        
        // 
        NSString *left = self.oneCol[leftRow];
        NSLog(@"%@ - %@", left, right);
    }
    //NSLog(@"-------row=%d, col=%d", row, component);
}
@end

H:/0712/07_UIPickerView 자정의 행MJViewController.h
//
//  MJViewController.h
//  07-UIPickerView-      
//
//  Created by apple on 13-7-12.
//  Copyright (c) 2013  itcast. All rights reserved.
/*
UIPickView      :
1,             
[pickerView selectedRowInComponent:0];
2,         ,   
  UIPickerView     :  numberOfComponentsInPickerView
  numberOfRowsInComponent,        
3,    :
	   component  row       title
	          :didSelectRow:inComponent:
*/

#import <UIKit/UIKit.h>

@interface MJViewController : UIViewController
<UIPickerViewDataSource, UIPickerViewDelegate>

@end

H:/0712/07_UIPickerView 자정의 행MJViewController.m
//  MJViewController.m
//  07-UIPickerView-      
//  Created by apple on 13-7-12.
//  Copyright (c) 2013  itcast. All rights reserved.
/*
UIPickView      :
1,             
[pickerView selectedRowInComponent:0];
2,         ,   
  UIPickerView     :  numberOfComponentsInPickerView
  numberOfRowsInComponent,        
3,    :
	   component  row       title
	          :didSelectRow:inComponent:
	   component  row       UIView
	       rowHeightForComponent
*/
#import "MJViewController.h"
@interface MJViewController ()
//         
@property (nonatomic, strong) NSArray *flags;
@end
@implementation MJViewController
- (void)viewDidLoad
{
    [super viewDidLoad];
    //     
    NSBundle *bundle = [NSBundle mainBundle];
    NSString *path = [bundle pathForResource:@"flags.plist" ofType:nil];
    self.flags = [NSArray arrayWithContentsOfFile:path];
}
#pragma mark      :    
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 1;
}
#pragma mark      :    
- (NSInteger)pickerView:(UIPickerView *)pickerView 
					numberOfRowsInComponent:(NSInteger)component
{
    return self.flags.count;
}
#pragma mark    component  row       UIView
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row
				forComponent:(NSInteger)component reusingView:(UIView *)view
{
    UIView *myview = [[UIView alloc] init];
    CGFloat myviewH = 40;
    CGFloat myviewW = 200;
    myview.bounds = CGRectMake(0, 0, myviewW, myviewH);
    NSDictionary *dict = self.flags[row];
    //     
    UILabel *label = [[UILabel alloc] init];
    CGFloat labelWidth = 120;
    label.frame = CGRectMake(0, 0, labelWidth, myviewH);
    label.text = dict[@"name"];
    label.textAlignment = NSTextAlignmentCenter;
    label.backgroundColor = [UIColor clearColor];
    [myview addSubview:label];
    //     
    UIImageView *imageView = [[UIImageView alloc] init];
    imageView.frame = CGRectMake(labelWidth, 0, myviewW - labelWidth, myviewH);
    imageView.image = [UIImage imageNamed: dict[@"icon"] ];
    [myview addSubview:imageView];
    return myview;
}
//     :       
- (CGFloat)pickerView:(UIPickerView *)pickerView 
					rowHeightForComponent:(NSInteger)component
{
    return 70;
}
@end

H:/0712/segment_그림 배열images.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
	<string>010.png</string>
	<string>011.png</string>
	<string>012.png</string>
	<string>013.png</string>
	<string>014.png</string>
	<string>015.png</string>
	<string>016.png</string>
	<string>017.png</string>
	<string>018.png</string>
</array>
</plist>

H:/0712/segment_그림 배열MJViewController.h
//  MJViewController.h
//      
//  Created by mj on 13-7-8.
//  Copyright (c) 2013  itcast. All rights reserved.

#import <UIKit/UIKit.h>

@interface MJViewController : UIViewController
//     ,    segmentControl  
- (IBAction)columnChange:(UISegmentedControl *)sender;

@end

H:/0712/segment_그림 배열MJViewController.m
//  MJViewController.m
//      
//  Created by mj on 13-7-8.
//  Copyright (c) 2013  itcast. All rights reserved.
#define kIconWidth 60
#define kIconHeight 60
#import "MJViewController.h"
@interface MJViewController ()
//     Plist      
@property (nonatomic, strong) NSArray *images;
//   ,    :   UIImageView
@property (nonatomic, strong) NSMutableArray *imageViews;
@end
@implementation MJViewController
- (void)viewDidLoad
{
    [super viewDidLoad];
    // 1.    
    NSString *path = [[NSBundle mainBundle] pathForResource:@"images.plist"
													ofType:nil];
	//        plist      
    self.images = [NSArray arrayWithContentsOfFile:path];
	//     ,       UIImageView   
    self.imageViews = [NSMutableArray array];
    // 2.     UIImageView
    for (int i = 0; i<self.images.count; i++)
    {
        UIImageView *imageView = [[UIImageView alloc] init];
        imageView.image = [UIImage imageNamed:self.images[i]];
        [self.view addSubview:imageView];
        [self.imageViews addObject:imageView];
    }
    // 3.     ,    
    [self columnChange:nil];
}
//     ,    segmentControl  
- (IBAction)columnChange:(UISegmentedControl *)sender
{
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.3];
	// segmentControl     0    ,       2 3 4,    =  +2
    int column = sender.selectedSegmentIndex + 2;
	//   :         :(   -  *     )/(  +1)
    CGFloat horMargin = (self.view.frame.size.width - column * kIconWidth)/(column + 1);
    CGFloat verticalMargin = 10;
    CGFloat startX = horMargin;
    CGFloat startY = 60;
    for (int i = 0; i<self.imageViews.count; i++)
    {
		//   ~   i   ,  :row col 
		//    i/  
        int row = i / column; 
		//      i%  
        int col = i % column;
		//  i  x   : 0  x +       * (    +       );
        CGFloat x = startX + col * (kIconWidth + horMargin);
		//  i  y   : 0  y +       * (    +       );
        CGFloat y = startY + row * (kIconHeight + verticalMargin);
        CGRect frame = CGRectMake(x, y, kIconWidth, kIconHeight);
		//          i   ,    frame    
        UIImageView *imageView = self.imageViews[i];
        imageView.frame = frame;
    }
    [UIView commitAnimations];
}
@end

H: / 0712 / 슬라이더 그림 변경images.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
	<dict>
		<key>icon</key>
		<string>0.png</string>
		<key>title</key>
		<string>    ,          !</string>
	</dict>
	<dict>
		<key>icon</key>
		<string>1.png</string>
		<key>title</key>
		<string>        ,         ?</string>
	</dict>
	<dict>
		<key>icon</key>
		<string>2.png</string>
		<key>title</key>
		<string>          ,         ,    </string>
	</dict>
	<dict>
		<key>icon</key>
		<string>3.png</string>
		<key>title</key>
		<string>        ,       </string>
	</dict>
	<dict>
		<key>icon</key>
		<string>4.png</string>
		<key>title</key>
		<string>     </string>
	</dict>
	<dict>
		<key>icon</key>
		<string>5.png</string>
		<key>title</key>
		<string>         </string>
	</dict>
	<dict>
		<key>icon</key>
		<string>6.png</string>
		<key>title</key>
		<string>    SB  </string>
	</dict>
	<dict>
		<key>icon</key>
		<string>7.png</string>
		<key>title</key>
		<string>   ?</string>
	</dict>
	<dict>
		<key>icon</key>
		<string>8.png</string>
		<key>title</key>
		<string> ,         ?  </string>
	</dict>
	<dict>
		<key>icon</key>
		<string>9.png</string>
		<key>title</key>
		<string>           ?</string>
	</dict>
	<dict>
		<key>icon</key>
		<string>10.png</string>
		<key>title</key>
		<string>        !</string>
	</dict>
	<dict>
		<key>icon</key>
		<string>11.png</string>
		<key>title</key>
		<string>       </string>
	</dict>
	<dict>
		<key>icon</key>
		<string>12.png</string>
		<key>title</key>
		<string>               </string>
	</dict>
	<dict>
		<key>icon</key>
		<string>13.png</string>
		<key>title</key>
		<string>  TMD   </string>
	</dict>
	<dict>
		<key>icon</key>
		<string>14.png</string>
		<key>title</key>
		<string>        ,    </string>
	</dict>
	<dict>
		<key>icon</key>
		<string>15.png</string>
		<key>title</key>
		<string>     P          </string>
	</dict>
</array>
</plist>

H: / 0712 / 슬라이더 그림 변경MJViewController.h
//  MJViewController.h
//       
//  Created by mj on 13-7-8.
//  Copyright (c) 2013  itcast. All rights reserved.
#import <UIKit/UIKit.h>
@interface MJViewController : UIViewController
- (IBAction)nightMode:(UISwitch *)sender;
//   :UIImageView
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
//   :      
@property (weak, nonatomic) IBOutlet UILabel *imageTitle;
//   :       
@property (weak, nonatomic) IBOutlet UILabel *imageNo;
//   :UISlider   ,      
@property (weak, nonatomic) IBOutlet UISlider *slider;
//   :UIStepper-----------------
@property (weak, nonatomic) IBOutlet UIStepper *stepper;
//   :      view
@property (weak, nonatomic) IBOutlet UIView *settingView;
//        ,          
- (IBAction)imageChange:(UISlider *)sender;
//          ,          view
- (IBAction)setting;
@end

H: / 0712 / 슬라이더 그림 변경MJViewController.m
//  MJViewController.m
//       
//  Created by mj on 13-7-8.
//  Copyright (c) 2013  itcast. All rights reserved.
#import "MJViewController.h"
@interface MJViewController ()
//     ,     ,  ,      
@property (nonatomic, strong) NSArray *images;
@end
@implementation MJViewController
- (void)viewDidLoad
{
    [super viewDidLoad];
    // 1.      
    NSString *path = [[NSBundle mainBundle] pathForResource:@"images.plist"
											ofType:nil];
	//     ,     ,  ,      										
    self.images = [NSArray arrayWithContentsOfFile:path];
    // 2.     
    //   slider   ,        -1,  slider     0    
    self.slider.maximumValue = self.images.count - 1;
    //   slider    0   
    self.slider.minimumValue = 0;
	// ---------------------------
    self.stepper.minimumValue = 0;
	// ---------------------------
    self.stepper.maximumValue = self.images.count - 1;
    // 3.        
    [self imageChange:nil];
}

//        ,          
- (IBAction)imageChange:(UISlider *)sender {
    int value = sender.value;
    //       ---------------------------
    self.stepper.value = value;
    self.slider.value = value;
    NSDictionary *dict = self.images[value];
    //     
    self.imageTitle.text = dict[@"title"];
    //     
    self.imageNo.text = [NSString stringWithFormat:@"%d/%d", value + 1, self.images.count];
    //     
    self.imageView.image = [UIImage imageNamed:dict[@"icon"]];
}
//          ,          view
- (IBAction)setting {
    [UIView beginAnimations:nil context:nil];
	// viewHeight        
    CGFloat viewHeight = self.view.frame.size.height;
    CGRect rect = self.settingView.frame;
    if (rect.origin.y == viewHeight) {
		//     view Y     ,     ,       
        rect.origin.y = viewHeight - rect.size.height;
    } else {
		//     view      ,           
        rect.origin.y = viewHeight;
    }
    self.settingView.frame = rect;
    [UIView commitAnimations];
}
//     view       
- (IBAction)nightMode:(UISwitch *)sender {
	//        ,       ,    
    self.view.backgroundColor = sender.isOn?[UIColor darkGrayColor]:
								[UIColor whiteColor];
}
@end

H: / 0712 / 종합 예키보드 처리cities.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>provinces</key>
	<array>
		<string>  </string>
		<string>  </string>
		<string>  </string>
		<string>  </string>
		<string>  </string>
		<string>  </string>
		<string>  </string>
		<string>  </string>
		<string>  </string>
		<string>  </string>
		<string>  </string>
		<string>  </string>
		<string>   </string>
		<string>  </string>
		<string>  </string>
		<string>  </string>
		<string>  </string>
		<string>  </string>
		<string>  </string>
		<string>   </string>
		<string>  </string>
		<string>  </string>
		<string>  </string>
		<string>  </string>
		<string>  </string>
		<string>  </string>
		<string>  </string>
		<string>  </string>
		<string>  </string>
		<string>  </string>
		<string>  </string>
		<string>  </string>
		<string>  </string>
		<string>  </string>
	</array>
	<key>cities</key>
	<dict>
		<key>  </key>
		<array>
			<string>   </string>
			<string>   </string>
			<string>   </string>
			<string>   </string>
			<string>   </string>
			<string>   </string>
			<string>   </string>
			<string>    </string>
			<string>   </string>
			<string>   </string>
			<string>   </string>
			<string>   </string>
			<string>   </string>
			<string>   </string>
			<string>   </string>
			<string>    </string>
			<string>   </string>
			<string>   </string>
		</array>
		<key>  </key>
		<array>
			<string>  </string>
		</array>
		<key>  </key>
		<array>
			<string>  </string>
		</array>
		<key>  </key>
		<array>
			<string>  </string>
		</array>
		<key>  </key>
		<array>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>    </string>
			<string>     </string>
			<string>  </string>
			<string>   </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
		</array>
		<key>  </key>
		<array>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
		</array>
		<key>  </key>
		<array>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
		</array>
		<key>  </key>
		<array>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>   </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
		</array>
		<key>  </key>
		<array>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>   </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
		</array>
		<key>  </key>
		<array>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>   </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
		</array>
		<key>  </key>
		<array>
			<string>   </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>   </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>   </string>
		</array>
		<key>  </key>
		<array>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>   </string>
			<string>  </string>
			<string>   </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>   </string>
		</array>
		<key>   </key>
		<array>
			<string>   </string>
			<string>  </string>
			<string>    </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>   </string>
			<string>  </string>
			<string>   </string>
			<string>  </string>
			<string>   </string>
			<string>    </string>
			<string>   </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
		</array>
		<key>  </key>
		<array>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
		</array>
		<key>  </key>
		<array>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>   </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>   </string>
			<string>  </string>
		</array>
		<key>  </key>
		<array>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
		</array>
		<key>  </key>
		<array>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>   </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
		</array>
		<key>  </key>
		<array>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>   </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
		</array>
		<key>  </key>
		<array>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>   </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
		</array>
		<key>   </key>
		<array>
			<string>    </string>
			<string>    </string>
			<string>     </string>
			<string>  </string>
			<string>  </string>
			<string>    </string>
			<string>    </string>
			<string>  </string>
			<string>  </string>
			<string>     </string>
			<string>     </string>
			<string>   </string>
		</array>
		<key>  </key>
		<array>
			<string>  </string>
			<string>  </string>
			<string>   </string>
			<string>  </string>
			<string>  </string>
		</array>
		<key>  </key>
		<array>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
		</array>
		<key>  </key>
		<array>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>   </string>
			<string>   </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>   </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
		</array>
		<key>  </key>
		<array>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
		</array>
		<key>  </key>
		<array>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
		</array>
		<key>  </key>
		<array>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
		</array>
		<key>  </key>
		<array>
			<string>    </string>
			<string>   </string>
			<string>   </string>
			<string>   </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>    </string>
			<string>   </string>
			<string>   </string>
			<string>    </string>
			<string>   </string>
			<string>   </string>
			<string>  </string>
		</array>
		<key>  </key>
		<array>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>   </string>
			<string>  </string>
		</array>
		<key>  </key>
		<array>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>    </string>
			<string>  </string>
			<string>  </string>
		</array>
		<key>  </key>
		<array>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
		</array>
		<key>  </key>
		<array>
			<string>  </string>
		</array>
		<key>  </key>
		<array>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
		</array>
		<key>  </key>
		<array>
			<string>  </string>
		</array>
		<key>  </key>
		<array>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>  </string>
			<string>   </string>
		</array>
	</dict>
</dict>
</plist>

H: / 0712 / 종합 예키보드 처리KeyboardTool.h
//  KeyboardTool.h
//           -    
//  Created by mj on 13-4-16.
//  Copyright (c) 2013  itcast. All rights reserved.
#import <UIKit/UIKit.h>
//     
@protocol KeyboardToolDelegate;
//        KeyboardToolButtonType
typedef enum {
    kKeyboardToolButtonTypeNext, //      :     
    kKeyboardToolButtonTypePrevious, //      :     
    kKeyboardToolButtonTypeDone //      :    
} KeyboardToolButtonType;
@interface KeyboardTool : UIToolbar
//     ,  ,      ,   ,    
@property (nonatomic, readonly) IBOutlet UIBarButtonItem *nextBtn;
@property (nonatomic, readonly) IBOutlet UIBarButtonItem *previousBtn;
@property (nonatomic, readonly) IBOutlet UIBarButtonItem *doneBtn;
//     _toolDelegate,      ,   assign  
@property (nonatomic, weak) id<KeyboardToolDelegate> toolDelegate;
+ (id)keyboardTool;
//      -      xib   
- (IBAction)next;
- (IBAction)previous;
- (IBAction)done;
@end
//           ,  1    KeyboardTool  ,  2     
@protocol KeyboardToolDelegate <NSObject>
- (void)keyboardTool:(KeyboardTool *)tool
			buttonClick:(KeyboardToolButtonType)type;
@end

H: / 0712 / 종합 예키보드 처리KeyboardTool.m
//  KeyboardTool.m
//           -    
//  Created by mj on 13-4-16.
//  Copyright (c) 2013  itcast. All rights reserved.
#import "KeyboardTool.h"
@implementation KeyboardTool
#pragma mark    , xib        KeyboardTool  
+ (id)keyboardTool {
    // owner   KeyboardTool   
    //   "   "     ,   owner next      
    NSArray *array = [[NSBundle mainBundle] 
			loadNibNamed:@"keyboardTool" owner:nil options:nil];    
    //         KeyboardTool  
    return [array lastObject];
}

#pragma mark -       ,       ,   ,    
- (void)next {
	//     _toolDelegate,     
    if ([_toolDelegate respondsToSelector:@selector(keyboardTool:buttonClick:)]) {
		//           ,       
		// self     KeyboardTool,            
        [_toolDelegate keyboardTool:self buttonClick:kKeyboardToolButtonTypeNext];
    }
}
- (void)previous {
	//     _toolDelegate,     
    if ([_toolDelegate respondsToSelector:@selector(keyboardTool:buttonClick:)]) {
		//           ,       
		// self     KeyboardTool,            
        [_toolDelegate keyboardTool:self buttonClick:kKeyboardToolButtonTypePrevious];
    }
}
- (void)done {
	//     _toolDelegate,     
    if ([_toolDelegate respondsToSelector:@selector(keyboardTool:buttonClick:)]) {
		//           ,       
		// self     KeyboardTool,            
        [_toolDelegate keyboardTool:self buttonClick:kKeyboardToolButtonTypeDone];
    }
}
@end

H: / 0712 / 종합 예키보드 처리MJViewController.h
//  MJViewController.h
//      
//  Created by mj on 13-7-9.
//  Copyright (c) 2013  itcast. All rights reserved.
#import <UIKit/UIKit.h>
#import "KeyboardTool.h"

@interface MJViewController : UIViewController 
<UITextFieldDelegate, UIPickerViewDataSource, UIPickerViewDelegate,
 KeyboardToolDelegate>
//       
@property (weak, nonatomic) IBOutlet UITextField *birthdayView;
//      
@property (weak, nonatomic) IBOutlet UITextField *cityView;

@end

H: / 0712 / 종합 예키보드 처리MJViewController.m
//  MJViewController.m
//      
//  Created by mj on 13-7-9.
//  Copyright (c) 2013  itcast. All rights reserved.
#import "MJViewController.h"
@interface MJViewController ()
//   ,       
@property (nonatomic, strong) NSArray *allProvinces;
//   ,    ,    ,           
@property (nonatomic, strong) NSDictionary *allCities;
//       
@property (nonatomic, weak) UITextField *activeTextField;
//          
@property (nonatomic, weak) KeyboardTool *tool;
//   ,           
@property (nonatomic, strong) NSMutableArray *allTextFields;
@end
@implementation MJViewController
- (void)viewDidLoad
{
    [super viewDidLoad];
	//     ,            
    self.allTextFields = [NSMutableArray array];
	//      ,       
    self.tool = [KeyboardTool keyboardTool];
	//              :     
    self.tool.toolDelegate = self;
    //              
    for (UITextField *field in self.view.subviews)
    {
		//          ,  ~
        if (![field isKindOfClass:[UITextField class]]) continue;
		//            KeyboardTool
        field.inputAccessoryView = self.tool;
		//   ,      ,        
        [self.allTextFields addObject:field];        
        //                 
        field.delegate = self;
    }
    //        UIDatePicker(         )
    UIDatePicker *datePicker = [[UIDatePicker alloc] init];
    //            
    datePicker.locale = [[NSLocale alloc]
						initWithLocaleIdentifier:@"zh_CN"];
    //      
    datePicker.datePickerMode = UIDatePickerModeDate;
    //   datePicker   
    [datePicker addTarget:self action:@selector(dateChange:)
					forControlEvents:UIControlEventValueChanged];
	//           UIDatePicker
    self.birthdayView.inputView = datePicker;
    //        UIPickerView
    UIPickerView *picker = [[UIPickerView alloc] init];
	// UIPickerView          
    picker.dataSource = self;
	//          UIPickerView   
    picker.showsSelectionIndicator = YES;
	// UIPickerView          
    picker.delegate = self;
	//           UIPickerView
    self.cityView.inputView = picker;
    //         
    NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile: 
					[[NSBundle mainBundle] pathForResource:@"cities.plist" 
					ofType:nil]];
	//  1        ,     allProvinces  
    self.allProvinces = dict[@"provinces"];
	//  2             ,     allCities  
    self.allCities = dict[@"cities"];
}
#pragma mark       UIDatePicker     
- (void)dateChange:(UIDatePicker *)picker
{
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = @"yyyy-MM-dd";
	//                        
    self.birthdayView.text = [formatter stringFromDate:picker.date];
}
#pragma mark UIPickerView     ,     
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 2;
}
#pragma mark UIPickerView     ,        
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    if (component == 0) {
        return self.allProvinces.count;
    } else {
        //        
        NSUInteger pIndex = [pickerView selectedRowInComponent:0];
		//      ,    
        NSString *pName = self.allProvinces[pIndex];
        //   KEY  ,             
        NSArray *cities = self.allCities[pName];
        return cities.count;
    }
}
#pragma mark UIPickerView    ,          
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    if (component == 0) {
		//     
        return self.allProvinces[row];
    } else {
        //        
        NSUInteger pIndex = [pickerView selectedRowInComponent:0];
		//     
        NSString *pName = self.allProvinces[pIndex];
        //            
        NSArray *cities = self.allCities[pName];
        return cities[row];
    }
}
#pragma mark UIPickerView    ,          
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row 
									inComponent:(NSInteger)component
{
    //   -----       ,      1    
    [pickerView reloadComponent:1];
	// selectedRowInComponent   0      
    NSUInteger pIndex = [pickerView selectedRowInComponent:0];
    NSString *pName = self.allProvinces[pIndex];
	// selectedRowInComponent   1      
    NSUInteger cIndex = [pickerView selectedRowInComponent:1];
    NSArray *cities = self.allCities[pName];
    NSString *cName = cities[cIndex];
	//             
    self.cityView.text = [NSString stringWithFormat:@"%@ %@", pName, cName];
}
#pragma mark - UITextField    ,         
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
	//        ,     
    [self.view endEditing:YES];
    return YES;
}
#pragma mark - UITextField    ,            
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
	//                    ,   
    NSUInteger index = [self.allTextFields indexOfObject:textField];
	//     index,           
    self.tool.previousBtn.enabled = index != 0;
	//     index,           
    self.tool.nextBtn.enabled = index != self.allTextFields.count - 1;	
    //                 ,         
    self.activeTextField = textField;
}
#pragma mark - Keytool  
- (void)keyboardTool:(KeyboardTool *)tool
					buttonClick:(KeyboardToolButtonType)type
{
    if (type == kKeyboardToolButtonTypeDone) {
		//      KeyTool      ,      
        [self.activeTextField resignFirstResponder];
    } else {		
		//                          
        NSUInteger index = [self.allTextFields indexOfObject:self.activeTextField];
        if (type == kKeyboardToolButtonTypePrevious) {
		//      KeyTool       
            index--;
        } else {
		//      KeyTool       
            index++;
        }
		//              ,        ,    
        UITextField *field = self.allTextFields[index];
        [field becomeFirstResponder];
    }
}

@end

좋은 웹페이지 즐겨찾기