我有一个问题,我将 UIScrollview 添加到我的 UIViewController,但我的 UIScrollview 不想滚动。我希望它的工作方式与它在 UITableViewController 上的工作方式相同。
在这里我初始化我的 UIScrollview
UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 800)];
scroll.contentSize = CGSizeMake(320, 800);
scroll.backgroundColor = [UIColor redColor];
scroll.showsHorizontalScrollIndicator = YES;
scroll.scrollEnabled = YES;
scroll.userInteractionEnabled=YES;
[self.view addSubview:scroll];
在这里,我将我的内容添加到滚动视图:
UILabel *memberNo = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 100, 20)];
memberNo.text = @"Member No";
memberNo.font = [UIFont boldSystemFontOfSize:16];
memberNo.textColor = [UIColor limeColor];
[scroll addSubview:memberNo];
memberText = [[UITextField alloc] initWithFrame:CGRectMake(10, 40, 300, 30)];
memberText.placeholder = @"Member No";
memberText.borderStyle = UITextBorderStyleRoundedRect;
memberText.text = @"1111111";
[scroll addSubview:memberText];