Мне было интересно, можно ли динамически создать подвид (страницу) для моего UIScrollView
. Мне просто нужно, чтобы было 2 UILabel
. Один сверху и один снизу. Если это возможно, может ли кто-нибудь сказать мне, как это сделать, или указать мне учебник/видео?
Я использовал учебник, и у меня все получилось очень хорошо. Но у него только 1 UILabel
внизу. Ссылка на него находится здесь http://www.iosdevnotes.com/2011/03/uiscrollview-paging/
Это то, где я думаю, что большая часть действия.
_objects = [[NSArray alloc] initWithObjects:@"",@"Does not include today", @"This does include today", @"Does not include today", @"This does include today", @"Includes the weekends!", nil];
_detailLabel1 = [[UILabel alloc] initWithFrame:CGRectMake(100.0, 0.0, 320.0, 460.0)];
_detailLabel1.textAlignment = UITextAlignmentCenter;
_detailLabel1.font = [UIFont boldSystemFontOfSize:15.0];
_detailLabel1.textColor=[UIColor whiteColor];
_detailLabel1.backgroundColor=[UIColor colorWithWhite:(CGFloat)1 alpha:(CGFloat)0];
_detailLabel2 = [[UILabel alloc] initWithFrame:CGRectMake(320.0, 0.0, 320.0, 460.0)];
_detailLabel2.textAlignment = UITextAlignmentCenter;
_detailLabel2.font = [UIFont boldSystemFontOfSize:15.0];
_detailLabel2.textColor=[UIColor whiteColor];
_detailLabel2.backgroundColor=[UIColor colorWithWhite:(CGFloat)1 alpha:(CGFloat)0];
_detailLabel3 = [[UILabel alloc] initWithFrame:CGRectMake(640.0, 0.0, 320.0, 460.0)];
_detailLabel3.textAlignment = UITextAlignmentCenter;
_detailLabel3.font = [UIFont boldSystemFontOfSize:15.0];
_detailLabel3.textColor=[UIColor whiteColor];
_detailLabel3.backgroundColor=[UIColor colorWithWhite:(CGFloat)1 alpha:(CGFloat)0];
// We are going to show all the contents of the _objects array
// using only these three UILabel instances, making them jump
// right and left, replacing them as required:
[scrollView addSubview:_detailLabel1];
[scrollView addSubview:_detailLabel2];
[scrollView addSubview:_detailLabel3];
У меня есть другой код в других местах, но здесь, я думаю, основная его часть.