开发者

loading multiple view controllers in a page scroll view and its interaction

I need to implement a page scroll view. Each page view should load a separate view controller. On performing actions/events on the view controller should update/refresh the pag开发者_StackOverflow社区e view.Is it possible? If yes , how? It would be very much grateful If you are able to give me pointers in this regard.


-(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];        
  }

its a sample code .... try it with changes... hope that finally work for you...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜