2

我是 iOS 应用程序开发的新手。我正在制作一个应用程序,我想在滚动视图上显示自定义视图并在滚动视图上添加视图,但它显示的是第一个视图的视图。我可以先获得第二个视图吗?

scrollview=[[UIScrollView alloc]initWithFrame:CGRectMake(0,80,320,360)];
[scrollview setContentSize:CGSizeMake(2550,360)];
[scrollview setScrollEnabled:YES];
[scrollview setPagingEnabled:YES];
[scrollview setBackgroundColor:[UIColor clearColor]];
scrollview .indicatorStyle = UIScrollViewIndicatorStyleDefault;
scrollview.showsHorizontalScrollIndicator = NO;
scrollview.showsVerticalScrollIndicator = NO;
scrollview.scrollsToTop = NO;
scrollview.delegate = self;
scrollview.tag=500;
[self.view addSubview:scrollview];


afterloginPageControl=[[UIPageControl alloc]initWithFrame:CGRectMake(0, 440, 320, 25)];
afterloginPageControl.numberOfPages = 8;
afterloginPageControl.backgroundColor = [UIColor darkGrayColor];

afterloginPageControl.highlighted = YES;
afterloginPageControl.hidesForSinglePage = YES;
afterloginPageControl.currentPage = 0;
afterloginPageControl.selected = YES;
[afterloginPageControl addTarget:self action:@selector(changePage:) forControlEvents:UIControlEventTouchUpInside];
// create Pages..
//[self createPages];
// add View
[self.view addSubview:afterloginPageControl];


info=[[InfoView alloc]initWithFrame:CGRectMake(0,  80,315, 350)];
info.delegate=self;

info.backgroundColor=[UIColor whiteColor];

[scrollview addSubview:info];


update=[[UpdateViewControll alloc]initWithFrame:CGRectMake(320,  80,320, 350)];
update .delegate=self;
update.backgroundColor=[UIColor whiteColor];
[scrollview addSubview:update];


search=[[SearchViewControll alloc]initWithFrame:CGRectMake(640,  80,320, 350)];
//info.delegate=self;
search.backgroundColor=[UIColor whiteColor];
[scrollview addSubview:search];
4

1 回答 1

4

在滚动视图中添加视图后使用此代码viewDidLoad

[scrollview scrollRectToVisible:CGRectMake(320,  80,320, 350) animated:YES];
于 2012-12-14T11:41:43.413 回答