當我輸入下面的代碼,不被顯示在滾動視圖我添加文本框:的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