使用 objectAtIndex:indexPath.row 选择来更改滚动视图图像

发布于 2024-11-28 02:24:35 字数 153 浏览 3 评论 0原文

我正在开发一个 iOS 应用程序,要求用户在辅助视图中搜索列表,选择列表中的一个条目,然后关闭视图,并将 mainViewController 滚动视图图像调整到特定位置。

我已将选定的条目存储在变量中,但无法关闭视图,也无法弄清楚如何使用我的变量重置滚动视图。欢迎任何帮助。

I am developing an iOS app that requires the user to search a list in a secondary view, select an entry in the list, and this then closes the view, and adjusts the mainViewController scrollview image to a specific location.

I have stored the selected entry in a variable, but I can't get the view to close, or figure out how to reset the scrollview using my variable. Any help is welcome.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

羁〃客ぐ 2024-12-05 02:24:35

在保存选择的位置,设置 mainViewController 的内容偏移量。

然后,如果您通过 [view addSubView:] 显示辅助视图,

请调用 [secondViewController.view removeFromSuperView];

Where you save the selection, set the mainViewController's content offset.

Then if you displayed your secondary view by [view addSubView:]

Call [secondViewController.view removeFromSuperView];

半仙 2024-12-05 02:24:35

您如何显示要关闭的视图。如果您正在使用
[self.view addSubview:someView] 然后你可以调用 [someView removeFromSuperview];。如果您的问题是您试图让视图自行关闭,您可以在主 viewController 中创建一个函数 - (void)closeSomeView 来关闭视图。

至于调整scrollView,你只需要创建一个CGPoint并执行类似的操作

CGPoint somePoint = CGPointMake(xPosition, yPosition);
[scrollView setContentOffset:somePoint];

How are you displaying the view you want to close. If you are using
[self.view addSubview:someView] then you can call [someView removeFromSuperview];. If your problem is that your trying to have the view close its self, you can create a function - (void)closeSomeView in your main viewController that closes the view.

As for adjusting the scrollView you just need to create a CGPoint and do something like this

CGPoint somePoint = CGPointMake(xPosition, yPosition);
[scrollView setContentOffset:somePoint];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文