我正在添加页面(视图)以滚动视图,而视图在屏幕外像这样
-(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,问题仍然存在。
答案 0 :(得分:0)
尝试拨打[self.EDDescriptionScrollView layoutIfNeeded]
答案 1 :(得分:0)
[self.EDDescriptionScrollView setContentOffset:CGPointMake((pageNo*EDDescriptionScrollView.frame.size.width)+80, EDDescriptionScrollView.frame.size.height)];
“pageNo”应为“pageNo - 1”