
>在Xcode中设置新的iOS Single VIEw应用程序.
>将以下代码粘贴到VIEwController.m的实现中:
@implementation VIEwController- (voID)loadVIEw{ [self settableVIEw:[[UItableVIEw alloc] initWithFrame:CGRectZero style:UItableVIEwStylePlain]];}- (voID)vIEwDIDLoad{ [super vIEwDIDLoad]; [self setautomaticallyAdjustsScrollVIEwInsets:NO]; // [*]}- (voID)vIEwDIDLayoutSubvIEws{ UItableVIEw *tableVIEw = [self tableVIEw]; UIEdgeInsets insets = [tableVIEw contentInset]; // insets.top = [[self topLayoutGuIDe] length]; // [1] // insets.top = 100; // [2] [tableVIEw setContentInset:insets]; [tableVIEw setScrollindicatorInsets:insets];}#pragma mark - table vIEw data source- (NSInteger)tableVIEw:(UItableVIEw *)tableVIEw numberOfRowsInSection:(NSInteger)section{ return 100;}- (UItableVIEwCell *)tableVIEw:(UItableVIEw *)tableVIEw cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static Nsstring *CellIDentifIEr = @"Cell"; UItableVIEwCell *cell = [tableVIEw dequeueReusableCellWithIDentifIEr:CellIDentifIEr]; if (cell == nil) { cell = [[UItableVIEwCell alloc] initWithStyle:UItableVIEwCellStyleDefault reuseIDentifIEr:CellIDentifIEr]; } [[cell textLabel] setText:[Nsstring stringWithFormat:@"%d",[indexPath row]]]; return cell;}@end 我遇到的问题是:
>如果我取消注释标有[1]的行,应用正确的插入,但滚动表视图不再有效.当我尝试滚动时,表格会d出我的手指之后的初始滚动位置.这个行为也是通过对[self topLayoutGuIDe]的简单调用触发的,而不将结果分配给任何东西.
>如果我取消注释[2]而不是[1],则滚动工作. 100 pt的插图也被应用.但现在,初始滚动位置会自动调整,以使内容下滑状态栏.
([*]:这真的只是与含有导航控制器的任何东西相结合,在这个例子中我似乎并没有什么不同,但是我想禁用任何自动的行为,以确保.)
有什么明显的我做错了吗?我真的在这里亏了
解决方法 这绝对是iOS 7中的一个错误(似乎没有在7.1中修复),但似乎只影响UItableVIEwController.我切换到使用带有嵌入式UItableVIEw的UIVIEwController,因为我不使用静态单元格,并且不需要UItableVIEwController为您提供的任何“魔术”.一旦我手动连接了UItableVIEwDataSource和UItableVIEwDelegate,我就可以开始使用self.topLayoutGuIDe,而不会弄乱tableVIEw的contentSize.
这是一个可以接受的解决方法,直到苹果修复了这个BUG.
总结以上是内存溢出为你收集整理的ios – 调用topLayoutGuide完全滚动?全部内容,希望文章能够帮你解决ios – 调用topLayoutGuide完全滚动?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)