Iphone 在页面滚动视图中加载多个视图控制器及其交互
我需要实现一个页面滚动视图。每个页面视图都应该加载一个单独的视图控制器。在视图上执行操作/事件时,控制器应更新/刷新页面视图。是否可能?如果是,如何进行?如果你能在这方面给我指点,我将不胜感激Iphone 在页面滚动视图中加载多个视图控制器及其交互,iphone,Iphone,我需要实现一个页面滚动视图。每个页面视图都应该加载一个单独的视图控制器。在视图上执行操作/事件时,控制器应更新/刷新页面视图。是否可能?如果是,如何进行?如果你能在这方面给我指点,我将不胜感激 -(无效)创建滚动视图 -(void)createScrollView { myScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 440)]; myScroll.pagingEnabled = YES; myScroll.
-(无效)创建滚动视图
-(void)createScrollView
{
myScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 440)];
myScroll.pagingEnabled = YES;
myScroll.showsHorizontalScrollIndicator = YES;
myScroll.showsVerticalScrollIndicator = YES;
myScroll.scrollsToTop = NO;
myScroll.delegate = self;
int n = [array count];
myScroll.contentSize = CGSizeMake((320 * n), 440); // n = number of views
for (int i = 0 , X = 0; i < [photoArray count]; i++ , X += 320)
{
UIImageView *img =[[UIImageView alloc]initWithFrame:CGRectMake(X,0, 320, 480)]; //here view for you
CGRect frame;
frame.size.width=320; frame.size.height=240;
frame.origin.x=0; frame.origin.y=88;
[img addSubview:asyncImage];
img.contentMode=UIViewContentModeScaleAspectFit;
[myScroll addSubview:img];
}
}
- (void) viewDidLoad
{
[self createScrollView];
[myScroll scrollRectToVisible:CGRectMake(320*photoNumber, 0, 320 , 240) animated:NO];
[self.view addSubview:myScroll];
}
{
myScroll=[[UIScrollView alloc]initWithFrame:CGRectMake(0,0320440)];
myScroll.paginEnabled=是;
myScroll.showshorizontalscrolindicator=YES;
myScroll.showsVerticalScrollIndicator=是;
myScroll.scrollsToTop=否;
myScroll.delegate=self;
int n=[数组计数];
myScroll.contentSize=CGSizeMake((320*n),440);//n=视图数
对于(int i=0,X=0;i<[photoArray count];i++,X+=320)
{
UIImageView*img=[[UIImageView alloc]initWithFrame:CGRectMake(X,0,320,480)];//这里是您的视图
CGRect帧;
frame.size.width=320;frame.size.height=240;
frame.origin.x=0;frame.origin.y=88;
[img addSubview:asyncImage];
img.contentMode=UIViewContentModeScaleSpectFit;
[myScroll addSubview:img];
}
}
-(无效)viewDidLoad
{
[自创建滚动视图];
[myScroll scrollRectToVisible:CGRectMake(320*photoNumber,03203240)动画:否];
[self.view addSubview:myScroll];
}
这是一个示例代码。。。。尝试改变它。。。希望最终能为你工作