我有一个ViewController,在ViewController中有一个滚动视图,而滚动视图包含两个Container View。在底部Container有两个文本字段。键盘时如何使滚动视图向上移动?感谢。
这是我的追求。
ViewContrller.h
@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet UIScrollView *scroll_view;
@end
ViewController.m
#import "ViewController.h"
#import "ControlXYViewController.h"
#import "FirstSubViewController.h"
@interface ViewController ()
@property (weak ,nonatomic) FirstSubViewController *first_sub_view;
@property (weak, nonatomic) ControlXYViewController *control_xy_view;
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.control_xy_view.fs = self.first_sub_view;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"control_xy_view"]) {
self.control_xy_view = segue.destinationViewController;
}
else if ([segue.identifier isEqualToString:@"first_sub_view"]) {
self.first_sub_view = segue.destinationViewController;
}
}
ControllerXYViewController.h
#import <UIKit/UIKit.h>
#import "ViewController.h"
#import "FirstSubViewController.h"
@interface ControlXYViewController : UIViewController<UITextFieldDelegate>
@property (strong, nonatomic) UIView *add_view;
@property (weak, nonatomic) IBOutlet UITextField *inputX;
@property (weak, nonatomic) IBOutlet UITextField *inputY;
@property (weak, nonatomic) ViewController *vc;
@property (weak, nonatomic) FirstSubViewController *fs;
@end
ControllerXYViewController.m
-(void)textFieldDidBeginEditing:(UITextField *)textField
{
}