当我输入下面的代码,不被显示在滚动视图我添加文本框:的TextField不被添加到滚动型
.H
@interface FirstViewController : UIViewController <UIScrollViewDelegate>
@property (strong, nonatomic) IBOutlet UIScrollView *scrollView;
@property (strong, nonatomic) UITextField *firstField;
@property (strong, nonatomic) UITextField *secondField;
@property (strong, nonatomic) UITextField *thirdField;
.M(viewDidLoad中)
self.firstField.placeholder = @"First";
self.firstField.textAlignment = NSTextAlignmentCenter;
self.firstField.font = [UIFont fontWithName:@"Helvetica Neue Light" size:50.0];
self.secondField.placeholder = @"Second";
self.secondField.textAlignment = NSTextAlignmentCenter;
self.secondField.font = [UIFont fontWithName:@"Helvetica Neue Light" size:50.0];
self.thirdField.placeholder = @"Third";
self.thirdField.textAlignment = NSTextAlignmentCenter;
self.thirdField.font = [UIFont fontWithName:@"Helvetica Neue Light" size:50.0];
[self.scrollView addSubview:self.firstField];
[self.firstField autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsZero excludingEdge:ALEdgeRight];
[self.firstField autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:self.scrollView];
[self.firstField autoMatchDimension:ALDimensionHeight toDimension:ALDimensionHeight ofView:self.scrollView];
[self.scrollView addSubview:self.secondField];
[self.secondField autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:self.firstField];
[self.secondField autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:self.scrollView];
[self.secondField autoMatchDimension:ALDimensionHeight toDimension:ALDimensionHeight ofView:self.scrollView];
[self.scrollView addSubview:self.thirdField];
[self.thirdField autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:self.secondField];
[self.thirdField autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsZero excludingEdge:ALEdgeLeft];
[self.thirdField autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:self.scrollView];
[self.thirdField autoMatchDimension:ALDimensionHeight toDimension:ALDimensionHeight ofView:self.scrollView];
self.automaticallyAdjustsScrollViewInsets = NO;
我有self.scrollView是在一个scrollView的方式(在pageviewcontroller)。我使用PureLayout来定位文本字段,并且我非常确定我做的方式是正确的。有什么我失踪?
我把这段代码放在'[self.scrollView addSubview:self.firstField]'后面,它仍然不显示。 – smecperson