界面: 多个选择器 与 UIScollView

Pre : 通知

textFieldDidEndEditing, 通知名称,
当 文本输入框 结束编辑, 才会调用 @selector(textFieldDidEndEditing:)

- (void)viewWillAppear:(BOOL)animated
{
    
    [[NSNotificationCenter defaultCenter ] addObserver:self selector: @selector(textFieldDidBeginEditing:) name:UIKeyboardWillShowNotification object: nil ];
    [[NSNotificationCenter defaultCenter ] addObserver: self selector:@selector(textFieldDidEndEditing:) name: UIKeyboardWillHideNotification object: nil];
}

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

开始 Try

UIView: CGRectOffset


- (void) animateTextField: (UITextField *) textField Up: (BOOL) isUp
{
   CGFloat vesselPadding = 120;
    CGFloat exePadding = (isUp ? vesselPadding : 0 );
   
 [UIView animateWithDuration: 0.5 animations:^{
        self.vesselView.frame = CGRectOffset(self.vesselView.frame, 0 ,  exePadding);
        
    } ];

解决: 选一下,就崩

UIView: CGAffineTransform

- (void) animateTextField: (UITextField *) textField Up: (BOOL) isUp
{
    CGFloat vesselPadding = 120;
    CGFloat exePadding = (isUp ? vesselPadding : 0 );

 CGAffineTransform pTransform = CGAffineTransformMakeTranslation(0, vesselPadding);
    //使视图使用这个变换

    self.vesselView.transform = pTransform;
}

解决:挡住 导航栏

ScrollView: CGPointMake

感谢:

NIB上给ScrollView添加Autolayout

iOS之UIScrollview添加约束图文详解

你可能感兴趣的:(界面: 多个选择器 与 UIScollView)