谢谢
- (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一起所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)