0
我做了一個UIScrollView,我正在給它添加子視圖。UIScrollView向上滾動到特定頁面?
但是當我水平滾動它時,它會在scollview時傳遞一些對象。
我的代碼是
#pragma mark - profileDataParsingFinish
-(void)profileDataParsingFinish:(MainUserDAO *)mainUserDAO
{
NSLog(@"Profile Data Parsing Finish ... ");
currentDao=mainUserDAO;
[headerScroll setContentSize:CGSizeMake(3200.0f, 110.0)];
NSString *newStr = [mainUserDAO.statusThumb substringWithRange:NSMakeRange(1, [mainUserDAO.statusThumb length]-1)];
NSURL *imageURL=[[NSURL alloc] initWithString:[NSString stringWithFormat:@"%@%@",serverPart,newStr]];
if([mainUserDAO.CityName isEqualToString:@"(null)"]){
}
else
[livesTitle setText:mainUserDAO.CityName];
[javaTitle setText:mainUserDAO.JobTitle];
if([currentDao.maritialStatusPrivacyId isEqualToString:@"1"]){
[maritialIcon setHidden:YES];
[maritialLabel setHidden:YES];
}
else if([currentDao.maritialStatusPrivacyId isEqualToString:@"2"]){
/*
<MaritalStatus><MaritalStatusID>1</MaritalStatusID><Title>Single</Title></MaritalStatus><MaritalStatus><MaritalStatusID>2</MaritalStatusID><Title>Engaged</Title></MaritalStatus><MaritalStatus><MaritalStatusID>3</MaritalStatusID><Title>In a relation</Title></MaritalStatus><MaritalStatus><MaritalStatusID>4</MaritalStatusID><Title>Married</Title></MaritalStatus><MaritalStatus><MaritalStatusID>5</MaritalStatusID><Title>Divorced</Title></MaritalStatus><MaritalStatus><MaritalStatusID>6</MaritalStatusID><Title>Widowed</Title></MaritalStatus><MaritalStatus><MaritalStatusID>7</MaritalStatusID><Title>Not interested</Title></MaritalStatus></ArrayOfMaritalStatus>
*/
if([currentDao.maritialStatusId isEqualToString:@"1"]){
[maritialLabel setText:@"Single"];
}
else
if([currentDao.maritialStatusId isEqualToString:@"2"]){
[maritialLabel setText:@"Engaged"];
}
else
if([currentDao.maritialStatusId isEqualToString:@"3"]){
[maritialLabel setText:@"In a relation"];
}
else
if([currentDao.maritialStatusId isEqualToString:@"4"]){
[maritialLabel setText:@"Married"];
}
else
if([currentDao.maritialStatusId isEqualToString:@"5"]){
[maritialLabel setText:@"Divorced"];
}
else
if([currentDao.maritialStatusId isEqualToString:@"6"]){
[maritialLabel setText:@"Widowed"];
}
else
if([currentDao.maritialStatusId isEqualToString:@"7"]){
[maritialLabel setText:@"Not Interested"];
}
[maritialIcon setHidden:NO];
[maritialLabel setHidden:NO];
// [maritialLabel setText:currentDao.]
}
// NSData *data=[[NSData alloc]initWithContentsOfURL:imageURL];
//[statusImage setImage:[UIImage imageWithData:data]];
if(mainUserDAO.statusThumb==nil || [mainUserDAO.statusThumb isEqualToString:@""]){
}
else{
FavouritImageDownloader *downloder=[[FavouritImageDownloader alloc]init];
[downloder startDownloading:mainUserDAO.statusThumb withButton:statusButton];
}
if([mainUserDAO.statusMessage isEqualToString:@""] || mainUserDAO.statusMessage==NULL)
[statusLine setText:@"No Status Message Found"];
else {
[statusLine setText:mainUserDAO.statusMessage];
}
int imagex=650;
int imagey=28;
if([mainUserDAO.horoscopeThumb length]<=5 || mainUserDAO.horoscopeThumb==nil || [mainUserDAO.horoscopeThumb isEqualToString:@""] || [mainUserDAO.horoscopeThumb rangeOfString:@"no-image"].length > 0);
else
{
// imagex=imagex+90;
UILabel *favTite=[[UILabel alloc]initWithFrame:CGRectMake(imagex+5, imagey-20, 100.0f, 15.0f)];
[favTite setTextColor:[UIColor blackColor]];
[favTite setBackgroundColor:[UIColor clearColor]];
[favTite setText:@"Horoscope"];
[headerScroll addSubview:favTite];
[favTite setFont:[UIFont boldSystemFontOfSize:12.0f]];
//UIImageView *horoscopeThumb=[[UIImageView alloc]initWithFrame:CGRectMake(imagex, imagey,77.0f , 77.0f)];
UIButton *horoscopeThumb=[UIButton buttonWithType:UIButtonTypeCustom];
[horoscopeThumb setFrame:CGRectMake(imagex, imagey,77.0f , 77.0f)];
[horoscopeThumb.imageView setContentMode:UIViewContentModeScaleAspectFit];
horoscopeThumb.layer.borderWidth=0.8f;
horoscopeThumb.layer.borderColor=[[UIColor whiteColor]CGColor];
if([currentDao.BirthPrvID isEqualToString:@"1"])
{
}
else if([currentDao.BirthPrvID isEqualToString:@"2"])
{
UILabel *ageLabel=[[UILabel alloc]initWithFrame:CGRectMake(55.0f, 55.0f, 20, 20)];
if(currentDao.Birthdate!=NULL)
[ageLabel setText:[self findDateDifference:currentDao.Birthdate]];
[ageLabel setTextColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"textcolor.png"]]];
[ageLabel setBackgroundColor:[UIColor clearColor]];
//[horoscopeThumb addSubview:ageLabel];
}
[horoscopeThumb setImage:[UIImage imageNamed:@"Placeholder.png"] forState:UIControlStateNormal];
horoscopeThumb.imageView.layer.borderWidth=0.8f;
horoscopeThumb.imageView.layer.borderColor=[[UIColor whiteColor] CGColor];
[favTite setFont:[UIFont boldSystemFontOfSize:12.0f]];
[headerScroll addSubview:horoscopeThumb];
FavouritImageDownloader *favDownload=[[FavouritImageDownloader alloc]init];
[favDownload startDownloading:currentDao.horoscopeThumb withButton:horoscopeThumb];
// [horoscopeThumb addTarget:self action:@selector(showHoroscopeDetail) forControlEvents:UIControlEventTouchUpInside];
[favDownload release];
}
if([mainUserDAO.friendThumb length]<=5 || mainUserDAO.friendThumb==nil || [mainUserDAO.friendThumb isEqualToString:@""] || [mainUserDAO.friendThumb rangeOfString:@"no-image"].length > 0);
else {
imagex=imagex+112;//2
UILabel *favTite=[[UILabel alloc]initWithFrame:CGRectMake(imagex+10, imagey-20, 70.0f, 15.0f)];
[favTite setTextColor:[UIColor blackColor]];
[favTite setBackgroundColor:[UIColor clearColor]];
[favTite setText:@"F.Friend"];
[favTite setTextAlignment:UITextAlignmentCenter];
[favTite setFont:[UIFont boldSystemFontOfSize:12.0f]];
[headerScroll addSubview:favTite];
UIButton *friendThumb=[UIButton buttonWithType:UIButtonTypeCustom];
[friendThumb setFrame:CGRectMake(imagex, imagey,77.0f , 77.0f)];
friendThumb.imageView.layer.borderWidth=0.8f;
friendThumb.imageView.layer.borderColor=[[UIColor whiteColor] CGColor];
[headerScroll addSubview:friendThumb];
favTite.center = friendThumb.center;
CGRect f = favTite.frame;
f.origin.y = imagey-20; // new y
favTite.frame = f;
FavouritImageDownloader *favdownloader=[[FavouritImageDownloader alloc]init];
[favdownloader startDownloading:currentDao.friendThumb withButton:friendThumb];
[friendThumb addTarget:self action:@selector(showFriendDetail) forControlEvents:UIControlEventTouchUpInside];
}
...............................// More Code here, I can't paste due to limit of Stack characters
[self.headerScroll scrollRectToVisible:CGRectMake(321,
self.headerScroll.frame.origin.y,
self.headerScroll.frame.size.width,
self.headerScroll.frame.size.height) animated:YES];
}
當我滾動,它省略了一些組件。
那麼我怎樣才能讓它滾動到特定的位置,它必須滾動。
在此先感謝
我需要把它們放到它滾動的位置。你能解釋一下嗎? –
添加完所有視圖之後,目前爲止我的手中沒有滾動條,除了在委託方法中處理它們之外,您有什麼建議? –
我想你正在尋找快照滾動,當你離開滾動它應該捕捉到一個視圖,對不對? – iphonic