如何使浏览器在ios中滚动
我有一个视图,我想滚动我的tableview滚动。
这是每当我滚动我的tableview将向上滚动的视图。 但是这是当我这样做时会发生什么:
你可以看到在我的目标视图和tableview之间有一个黑色的空间。
在我scrollViewDidScroll我做到了这一点:
CGPoint offset = scrollView.contentOffset; self.counter = 0; CGRect bounds = scrollView.bounds; CGSize size = scrollView.contentSize; UIEdgeInsets inset = scrollView.contentInset; float y = offset.y + bounds.size.height - inset.bottom; float h = size.height; float reload_distance = 10; float scrollViewHeight = scrollView.frame.size.height; float scrollContentSizeHeight = scrollView.contentSize.height; float scrollOffset = scrollView.contentOffset.y; self.tableData.contentInset = UIEdgeInsetsZero; if (scrollOffset == 0) { [self.topView removeFromSuperview]; [[self navigationController] setNavigationBarHidden:NO animated:YES]; [self changeHeight:48]; self.parentOfPhotoview.frame =CGRectMake(0, 0, self.parentOfPhotoview.frame.size.width, self.heightConstraint.constant); } else if(scrollOffset>2) { //[[self navigationController] setNavigationBarHidden:YES animated:YES]; //[self.view addSubview:_topView]; if(self.heightConstraint.constant<2) { [self changeHeight:0]; } else { [self changeHeight:48-(scrollView.contentOffset.y)]; self.parentOfPhotoview.frame = CGRectMake(0, -scrollView.contentOffset.y, self.parentOfPhotoview.frame.size.width, self.heightConstraint.constant); self.parentOfPhotoview.backgroundColor = [UIColor whiteColor]; NSLog(@"%f",self.heightConstraint.constant); } } else if (scrollOffset + scrollViewHeight == scrollContentSizeHeight) { // then we are at the end }
scrolloffset 0表示顶部, heightConstraint是parentOfPhotoview的高度约束,这是所需的视图!
我在想什么?
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 0; } -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ return 0; }
尝试上面的代码行。 可能是你的问题将被解决。
您应该设置您的表contentInset与顶部具有相同的高度作为navigationBar。 黑色是没有意见的时候。 这样你就不用担心改变tableView的高度等等
不过,我会build议使用AutoLayout。
另外,如果你想让parentPhotoView在表格的顶部浮动, 您在部分的标题视图中设置。
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
并确保您设置节的标头的高度是相同的parentPhotoView
- 在UITableView-XMLparsing中混合了图像
- 如何获取uitableview ios中viewwithtag的UIButton的索引
- 在编辑模式下的UITableView单元格中的UISwitch
- ' – :无法识别的select器发送到实例' – 试图找出原因
- 如何正确定位右侧的UITableView单元格子视图?
- iOS UITableViewCellAccessoryCheckmark每次滚动都可见
- 更改UITableViewCell的高度
- 如果在一个ViewController中使用两个UITableView,而另一个使用自定义单元格refrence,而另一个则很简单
- alignmentUITableView中的文本