【问题标题】:UIScrollView scrolling, when something deleted?UIScrollView 滚动,什么时候删除?
【发布时间】:2013-08-15 11:20:57
【问题描述】:

我有可以在 UIScrollView 中删除的元素。当我在滚动视图的底部删除某些内容时,我不想滚动到顶部,我想留在我删除元素的区域。

我已经搜索过了,但是还没有解决方案,

你有吗?

【问题讨论】:

  • 问题到底出在哪里?从UIScrollView 中删除元素本身不会执行任何滚动 - 它不会更改contentOffset
  • 我需要在删除元素的地方设置滚动偏移量?

标签: ios uiscrollview scroll


【解决方案1】:
CGRect Bound = [self.myViewName bounds]; // such like UIButton, UITextFiled .. etc.
CGPoint pt = Bound.origin;

[self.scrollView setContentOffset:pt animated:YES];

还有Read This Documentation.

【讨论】:

  • 你能解释一下吗
  • 你想删除什么元素??我的意思是它是 UIBUtton,UItextFiled // ??
  • 是由子视图组成的uiview
  • 我有多个这个视图,我可以做乘法吗,比如 row*[myview bounds]
  • 这里写下你想删除的name元素:)然后删除这个元素
【解决方案2】:

如果您(根据您的评论)想要滚动到 被删除组件的位置你可以这样做:

//get the frame of component being deleted

CGRect frameOfDeletedView = viewBeingDeleted.frame;

//set the content offset

[theScrollView scrollRectToVisible:frameOfDeletedView animated:NO];

//remove the component

//...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-07-28
    • 1970-01-01
    • 2014-10-06
    • 2018-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多