【发布时间】:2014-09-17 22:12:26
【问题描述】:
我的问题是我的 scrollView 的属性(是正确的词吗?)不起作用。我正在尝试让 scrollView 进入页面,但它似乎忽略了我的代码行
[scrollView setPagingEnabled:YES];
scrollView 上下滚动以及左右滚动(设置了 contentSize),但它不会捕捉到页面,并且测试其他不起作用的委托属性似乎是问题的结果这个。
似乎我在声明委托时做错了,委托应该是自我。这是我的 .h 的标题,它使 DayViewController 成为 UIScrollView 委托
@interface DayViewController : UIViewController <UIScrollViewDelegate> {
UIScrollView *scrollView;
//other code......
}
这是我的 .m 文件的相关部分,其中委托设置为 self,我尝试调整 UIScrollView 的属性。
- (void)viewDidLoad
{
[super viewDidLoad];
tester = [Global tester];
cal = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
viewsInMemory = [[NSMutableArray alloc] init];
for (int i = 0; i < 3; i++) {
[viewsInMemory insertObject:[NSNull null] atIndex:i];
}
scrollView = [[UIScrollView alloc] init];
scrollView.delegate = self;
[scrollView setScrollEnabled:YES];
[scrollView setPagingEnabled:YES];
scrollView = [[UIScrollView alloc] initWithFrame:(CGRectMake(0, 0, 320, self.view.frame.size.height))];
scrollView.backgroundColor = [UIColor lightGrayColor];
[self loadInitialDays];
[scrollView addSubview:(currentDayView)];
[self.view addSubview:(scrollView)];
}
我知道我的代码的其他部分可能看起来效率低下或其他什么,但这不是我寻求帮助的内容。我唯一需要的是让你们中的一个人弄清楚代表为什么不工作。非常感谢!
【问题讨论】:
-
您的滚动视图有效吗?你能做一个卷轴吗?
-
你设置了滚动的 contentSize 吗?
-
是的,scrollView 滚动并设置了 contentSize。唯一不起作用的是分页,它不会捕捉到页面。
-
请写出卷轴的 contentSize
标签: ios objective-c uiscrollview delegates scroll-paging