ios – 如何滚动标题与uitableview一起

ios – 如何滚动标题与uitableview一起,第1张

概述我有一个带标题的UITableView.我目前的问题是标题不会与表滚动.当用户滚动表视图时,我需要滚动屏幕(上图).桌面滚动,但标题被锁定在UIView的顶部. 谢谢 - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *sectionHeade 我有一个带标题的UItableVIEw.我目前的问题是标题不会与表滚动.当用户滚动表视图时,我需要滚动屏幕(上图).桌面滚动,但标题被锁定在UIVIEw的顶部.

谢谢

- (UIVIEw *)tableVIEw:(UItableVIEw *)tableVIEw vIEwForheaderInSection:(NSInteger)section {    UIVIEw *sectionheader = [[UILabel alloc] initWithFrame:CGRectNull];    sectionheader.backgroundcolor = [UIcolor whitecolor];    // add user profile image to _contentVIEw    UIImageVIEw *userImageVIEw;    UIImage *userImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:userProfileImageUrl]]];    userImageVIEw=[[UIImageVIEw alloc]initWithImage:userImage];    userImageVIEw.frame=CGRectMake(10,10,90,100);   [sectionheader addSubvIEw:userImageVIEw];   // return userImageVIEw;    // user name lable    CGRect usernameFrame = CGRectMake(110,60,100,50 );    UILabel* usernameLabel = [[UILabel alloc] initWithFrame: usernameFrame];    [usernameLabel setText: firstname];    [usernameLabel setTextcolor: [UIcolor blackcolor]];    [usernameLabel setBackgroundcolor:[UIcolor clearcolor]];    [usernameLabel setFont:[UIFont FontWithname:@"DIN-Regular" size:14]];    [sectionheader addSubvIEw:usernameLabel];    // user last name label    CGRect userLastnameFrame = CGRectMake(110,75,50 );    UILabel* userLastnameLabel = [[UILabel alloc] initWithFrame: userLastnameFrame];    [userLastnameLabel setText: lastname];    [userLastnameLabel setTextcolor: [UIcolor blackcolor]];    [userLastnameLabel setBackgroundcolor:[UIcolor clearcolor]];    [userLastnameLabel setFont:[UIFont FontWithname:@"DIN-Regular" size:14]];    [sectionheader addSubvIEw:userLastnameLabel];    // user checkin vIEw    UIVIEw *userCheckinVIEw = [[UIVIEw alloc] initWithFrame:CGRectMake(10,120,280,25)];    userCheckinVIEw.backgroundcolor = customcolorGrey;    [sectionheader addSubvIEw:userCheckinVIEw];    // check in label    UILabel* userCheckInLabel = [[UILabel alloc] initWithFrame:CGRectMake(40,2,20)];    [userCheckInLabel setText: @"CHECK-IN"];    userCheckInLabel.backgroundcolor = customcolorGrey;    userCheckInLabel.textcolor = customcolorIt;    [userCheckInLabel setFont:[UIFont FontWithname:@"DIN-Regular" size:12]];    [userCheckinVIEw addSubvIEw:userCheckInLabel];    // image    UIImageVIEw *checkinimg = [[UIImageVIEw alloc]                               initWithImage:[UIImage imagenamed:@"classifica_geotag_C.png"]];    checkinimg.frame = CGRectMake(5,24,24);    [userCheckinVIEw addSubvIEw:checkinimg];    // check in label    UILabel* userCheckInCountLabel = [[UILabel alloc] initWithFrame:CGRectMake(250,20,20)];    [userCheckInCountLabel setText: [checkinCount stringValue]];    userCheckInCountLabel.backgroundcolor = customcolorGrey;    userCheckInCountLabel.textcolor = customcolorIt;    [userCheckInCountLabel setFont:[UIFont FontWithname:@"DIN-Regular" size:12]];    [userCheckinVIEw addSubvIEw:userCheckInCountLabel];    // user like vIEw    UIVIEw *userlikeVIEw = [[UIVIEw alloc] initWithFrame:CGRectMake(10,150,25)];    userlikeVIEw.backgroundcolor = customcolorGrey;    [sectionheader addSubvIEw:userlikeVIEw];    // like label    UILabel* userlikeLabel = [[UILabel alloc] initWithFrame:CGRectMake(40,20)];    [userlikeLabel setText: @"liKE"];    userlikeLabel.backgroundcolor = customcolorGrey;    userlikeLabel.textcolor = customcolorIt;    [userlikeLabel setFont:[UIFont FontWithname:@"DIN-Regular" size:12]];    [userlikeVIEw addSubvIEw:userlikeLabel];    // image    UIImageVIEw *likeimg = [[UIImageVIEw alloc]                            initWithImage:[UIImage imagenamed:@"classifica_like_C.png"]];    likeimg.frame = CGRectMake(5,24);    [userlikeVIEw addSubvIEw:likeimg];    // user like label    UILabel* userlikeCountLabel = [[UILabel alloc] initWithFrame:CGRectMake(250,20)];    [userlikeCountLabel setText: [likesCount stringValue]];    userlikeCountLabel.backgroundcolor = customcolorGrey;    userlikeCountLabel.textcolor = customcolorIt;    [userlikeCountLabel setFont:[UIFont FontWithname:@"DIN-Regular" size:12]];    [userlikeVIEw addSubvIEw:userlikeCountLabel];    // la mia bacheca like vIEw    userLaMiaVIEw = [[UIVIEw alloc] initWithFrame:CGRectMake(10,180,300,25)];    userLaMiaVIEw.backgroundcolor = [UIcolor clearcolor];    [sectionheader addSubvIEw:userLaMiaVIEw];    // like label    UILabel* userLaMiaLabel = [[UILabel alloc] initWithFrame:CGRectMake(5,20)];    [userLaMiaLabel setText:NSLocalizedString(@"LA MIA BACHECA",nil)];    userLaMiaLabel.backgroundcolor = [UIcolor clearcolor];    userLaMiaLabel.textcolor = customcolorGrey;    [userLaMiaLabel setFont:[UIFont FontWithname:@"DIN-Bold" size:10]];    [userLaMiaVIEw addSubvIEw:userLaMiaLabel];    // grey line vIEw below la mia label    userGreylineVIEw = [[UIVIEw alloc] initWithFrame:CGRectMake(10,248,1.5)];    userGreylineVIEw.backgroundcolor = [UIcolor whitecolor];    [sectionheader addSubvIEw:userGreylineVIEw];    return sectionheader;}- (CGfloat)tableVIEw:(UItableVIEw *)tableVIEw heightForheaderInSection:(NSInteger)section {    return 210;}
解决方法 尝试在返回之前添加这一行sectionheader:
self.tableVIEw.tableheaderVIEw = sectionheader;
总结

以上是内存溢出为你收集整理的ios – 如何滚动标题与uitableview一起全部内容,希望文章能够帮你解决ios – 如何滚动标题与uitableview一起所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1108865.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存