单击按钮更改视图/是否需要在 iPhone 中使用同步方法?

发布于 2024-09-16 21:01:21 字数 399 浏览 4 评论 0原文

我已经创建了滚动视图并在滚动视图中设置了按钮。按钮水平滚动。我创建了表视图作为视图控制器的子视图。单击按钮后,数据将使用 XML 解析从 RSS 源显示在表视图中。因此,更改表视图中的数据取决于单击的按钮。当我更改为选择下一个按钮时,将开始解析并显示数据。所以需要一些时间。同时我想显示一些视图或禁用视图(这意味着,在解析时视图被禁用或用户无法执行任何操作,例如使用活动指示器冻结)。更改每个按钮时,将会发生相应的操作。我参考了一些教程,但我不明白?有人告诉我使用同步方法来解决问题。但我对此没有任何想法。请指导我并帮助我。给我一些示例应用程序和链接。

请参阅我的下图,

Image

提前致谢!

问候,
普加尔

I have created scroll view and set the buttons in the scroll view. The buttons are scrolling horizontally. I created table view as subview for view controller. On clicking the buttons, the datas are displaying in the table view from RSS feeds using XML Parsing. SO changing the datas in the table view which depends the button clicking. When i changed to select the next button, the parsing will be started and displayed the datas. so it takes some times. In the mean time i want to display some view or disable the view(that means,on that parsing time the view is disable or user cant do anything like freeze with activity indicator). On changing the each buttons, the action will be happened. I referred some tutorials, but i cant get any idea? Some people told me to use synchronous method to solved the problem. But i don't have any idea about it. Please guide me and help me out.Give me some sample apps and Links.

see my below image,

Image

Thanks in Advance!

Regards,
Pugal

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

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

发布评论

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

评论(1

你的背包 2024-09-23 21:01:21

不要使用同步网络调用来禁用用户输入。提出这个建议的人给了你非常糟糕的建议。

如果您只想禁用当前视图及其子视图的输入,您可以在视图控制器中执行 self.view.userInteractionEnabled = NO;

如果您想禁用整个窗口的输入,可以执行 self.view.window.userInteractionEnabled = NO;

如果您覆盖全屏视图,则根本不需要禁用用户交互在您的用户界面之上。根据您的模型图像,我认为这就是您想要做的。为此,您可以执行以下操作:

self.overlayView = [[[UIView alloc] initWithFrame:self.view.window.bounds] autorelease];
self.overlayView.backgroundColor = [UIColor blackColor];
self.overlayView.alpha = 0.5f;
[self.view.window addSubview:self.overlayView];
self.activityIndicator = [[[UIActivityIndicator alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite] autorelease];
self.activityIndicator.center = self.view.window.center;
[self.view.window addSubview:self.activityIndicator];
[self.activityIndicator startAnimating];
self.activityLabel = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
self.activityLabel.text = @"Loading...";
[self.activityLabel sizeToFit];
self.activityLabel.center = CGPointMake(self.activityIndicator.center.x, self.activityIndicator.center.y - self.activityIndicator.frame.size.height);
[self.view.window addSubview:self.activityLabel];

Don't use synchronous network calls to disable user input. Whoever suggested that gave you very bad advice.

If you just want to disable input for your current view and its subviews, you can do self.view.userInteractionEnabled = NO; in your view controller.

If you want to disable input for the entire window, you can do self.view.window.userInteractionEnabled = NO;

You won't need to disable user interaction at all if you overlay a full-screen view on top of your user interface. Based on your mock-up image, I think this is what you're trying to do. To do this, you can do something like this:

self.overlayView = [[[UIView alloc] initWithFrame:self.view.window.bounds] autorelease];
self.overlayView.backgroundColor = [UIColor blackColor];
self.overlayView.alpha = 0.5f;
[self.view.window addSubview:self.overlayView];
self.activityIndicator = [[[UIActivityIndicator alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite] autorelease];
self.activityIndicator.center = self.view.window.center;
[self.view.window addSubview:self.activityIndicator];
[self.activityIndicator startAnimating];
self.activityLabel = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
self.activityLabel.text = @"Loading...";
[self.activityLabel sizeToFit];
self.activityLabel.center = CGPointMake(self.activityIndicator.center.x, self.activityIndicator.center.y - self.activityIndicator.frame.size.height);
[self.view.window addSubview:self.activityLabel];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文