表视图框架在 xib 中具有额外的 y 原点后,将顶部设置为半透明条



将 top 设置为半透明条后,xib 中具有额外 y 原点的 TableView 帧,并且无法将表视图的偏移量设置为在 keyboardwillbehidden 后将 y 原点定位为 0

UIEdgeInsets contentInsets = UIEdgeInsetsZero;
self.documentdetailTable.contentInset = contentInsets;
self.documentdetailTable.scrollIndicatorInsets = contentInsets;
CGPoint scrollPoint = CGPointMake(0, 0);
[self.documentdetailTable setContentOffset:scrollPoint animated:NO];

上面是将表视图内容偏移量设置为(0,0)但最初是(0,64)总是这样,我不知道如何给出偏移量(0,0)。 最初表格默认处于(0,64,1024,800)帧和内容偏移量(0,64)

默认情况下,此 64 值由系统自动完成,因此您的内容不在导航栏下方。如果您希望自己保留对插图的控制,请将以下内容添加到视图控制器中:

- (BOOL)automaticallyAdjustsScrollViewInsets
{
    return NO;
}

自 iOS7 SDK 以来,UIViewController 中有两个新的属性extendedLayoutIncludesOpaqueBarsautomaticallyAdjustsScrollViewInsets

@property(nonatomic,assign) BOOL extendedLayoutIncludesOpaqueBars NS_AVAILABLE_IOS(7_0); // Defaults to NO, but bars are translucent by default on 7_0.  
@property(nonatomic,assign) BOOL automaticallyAdjustsScrollViewInsets NS_AVAILABLE_IOS(7_0); // Defaults to YES

extendedLayoutIncludesOpaqueBars 控制 UIViewController 中视图的帧 Y。 automaticallyAdjustsScrollViewInsets 控制 UIScrollView 的 contentInset(包含 UITableView)。您可以在XCode中找到Apple的文档集中的更多详细信息。也许这些可以帮助你。祝你好运!

最新更新