简体   繁体   English

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

[英]Use objectAtIndex:indexPath.row selection to change a scrollview image

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

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. 欢迎任何帮助。

Where you save the selection, set the mainViewController's content offset. 保存选择的位置,设置mainViewController的内容偏移量。

Then if you displayed your secondary view by [view addSubView:] 然后,如果您通过[view addSubView:]显示了辅助视图

Call [secondViewController.view removeFromSuperView]; 调用[secondViewController.view removeFromSuperView];

How are you displaying the view you want to close. 您如何显示要关闭的视图。 If you are using [self.view addSubview:someView] then you can call [someView removeFromSuperview];. 如果使用[self.view addSubview:someView],则可以调用[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. 如果您的问题是试图关闭视图自身,则可以在关闭视图的主viewController中创建一个函数-(void)closeSomeView。

As for adjusting the scrollView you just need to create a CGPoint and do something like this 至于调整scrollView,您只需要创建一个CGPoint并执行类似的操作

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM