如何知道哪个uiview用户正在使用

发布于 2024-12-23 14:15:00 字数 417 浏览 4 评论 0原文

我正在实现推送通知,并在用户使用应用程序时对其进行管理。因此,会出现一个警报视图,并且在视图上单击它必须重定向到 uiview。现在,如果用户在警报到来时显示 uiview,我怎样才能知道顶部的 uiview?我怎样才能更新当前的uiview?警报显示在应用程序委托的方法 didReceiveRemoteNotification 中。 谢谢

编辑: 我想做这样的事情:

UiviewController current* = [delegate getCurrentView];
if(current.toString=="NotificationView"){
   [current update:notificationText];
}else{
   saveNotification;
   goToNotificationView;
}

I'm implementing push notification and i'm managing it when user is using app. So an alert view appear and on view click it must redirect to an uiview. now if user is showing that uiview when alert is coming how can i know the uiview on top? how can i update the uiview current? Alert is shown in application delegate in the metod didReceiveRemoteNotification.
Thankss

EDIT:
i want to do something like this:

UiviewController current* = [delegate getCurrentView];
if(current.toString=="NotificationView"){
   [current update:notificationText];
}else{
   saveNotification;
   goToNotificationView;
}

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

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

发布评论

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

评论(1

缱绻入梦 2024-12-30 14:15:00

我认为您的主窗口中很可能有一个UINavigationController(它可以是UITabBarController等),但是如果您有一个>UINavigationController 在您的主窗口中,然后您可以使用[self.navigationController topViewController];UINavigationController的顶部视图控制器> 或者你可以还检查 UINavigationControllerviewControllers 堆栈,该堆栈返回您在 UINavigationController 中推送的所有视图控制器的数组,并且可以获取该 UINavigationController 的最后一个对象code>array 这是使用 [[self.navigationController viewControllers] lastObject]; 的顶视图。

如果您的主 window 中有一个 UITabBarController ,那么您可以使用 [ 获取 UINavigationController 的实例(如果存在) [self.tabbarcontroller viewControllers] objectAtIndex:[self.tabbarcontroller selectedIndex]]; 并且可以执行上述步骤来获取顶视图。

I think most probably you have a UINavigationController in your main window (it can be a UITabBarController,etc), but if you have a UINavigationController in your main window then you can check the top view controller of your UINavigationController by using [self.navigationController topViewController]; or you can also check for UINavigationController's viewControllers stack that returns an array of all view controller's you pushed in UINavigationController and can get the last object of that array which is your top view by using [[self.navigationController viewControllers] lastObject]; .

If you have a UITabBarController in your main window , then you can get the instance of UINavigationController (if its there) by using [[self.tabbarcontroller viewControllers] objectAtIndex:[self.tabbarcontroller selectedIndex]]; and can do the above steps to get the top view.

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