我是 iOS 应用程序开发的新手。我正在制作一个应用程序,我想在 ScrollView 上显示自定义 View 并在 ScrollView 上添加 View ,但它显示的是第一个 View 的 View 。我可以先获得第二个 View 吗?
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 actionselector(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];
在 viewDidLoad
中在 ScrollView 上添加 View 后使用此代码。
[scrollview scrollRectToVisible:CGRectMake(320, 80,320, 350) animated:YES];
关于iphone - 如何在应用程序启动时创建一个默认 View 以呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13877982/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |