0

我正在将页面(视图)添加到滚动视图,而视图像这样在屏幕外

-(void)loadScrollView:(NSInteger)CurrentPage
{
    int pageNo=objGameData.CurrentPageNo-1;
    [self.EDDescriptionScrollView setContentOffset:CGPointMake((pageNo*EDDescriptionScrollView.frame.size.width)+80, EDDescriptionScrollView.frame.size.height)];

    self.EDDescriptionScrollView.contentSize=CGSizeMake(EDDescriptionScrollView.frame.size.width*objGameData.CurrentPageNo,EDDescriptionScrollView.frame.size.height);




    edView=[[EDView alloc]initWithFrame:CGRectMake((CurrentPage-1)*EDDescriptionScrollView.frame.size.width, 0, EDDescriptionScrollView.frame.size.width, EDDescriptionScrollView.frame.size.height)];

    [edView.EDMsgTextView setText:[NSString stringWithFormat:@"%@",[self.EDDescrptionArray objectAtIndex:(CurrentPage-1)]]];
    edView.EDMsgTextView.delegate=self;
    edView.backgroundColor=[UIColor clearColor];
    edView.CorrectWordLbl.text=self.CurrentWord;
    edView.TotalPointsLost.text=[NSString stringWithFormat:@"Points : %d",objGameData.CurrentPointsLostEarned];
    edView.tag=pageNo;
    [self.EDDescriptionScrollView addSubview:edView];
}

现在,当我在屏幕上移动 EDDescriptionScrollView 的超级视图并想跳转到添加的最后一个页面以外的某个页面时,我只是这样做

 [self.EDDescriptionScrollView setContentOffset:CGPointMake((pageNo*EDDescriptionScrollView.frame.size.width)+80, EDDescriptionScrollView.frame.size.height)];

它将滚动视图带到页面,但内容仅在我触摸屏幕时显示。我在做什么是错的?我也试过调用layoutsubview,问题依然存在。

4

2 回答 2

0

试着打电话[self.EDDescriptionScrollView layoutIfNeeded]

于 2013-08-29T07:17:52.573 回答
0

[self.EDDescriptionScrollView setContentOffset:CGPointMake((pageNo*EDDescriptionScrollView.frame.size.width)+80, EDDescriptionScrollView.frame.size.height)]; “pageNo”应该是“pageNo - 1”

于 2016-08-08T11:51:25.693 回答