- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 iPad 的主从模板。我有一个 ViewController,我想以模态方式显示它,所以我使用了这段代码
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
m_ViewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
m_ViewController.modalPresentationStyle = UIModalPresentationFormSheet;
[appDelegate.splitViewController presentModalViewController:m_ViewController animated:YES];
这工作正常,ViewController 已模态加载,现在我试图关闭这个 ViewController,所以在 ViewController.m 中,我调用了这行代码
[self dismissModalViewControllerAnimated:YES];
这段代码也可以正常工作,并且 ViewController 被解雇,但是在解雇后我想在我的 MasterView 中调用一个函数。如何做到这一点?
根据与 Moxy 的讨论添加的代码。
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate.testViewController testfunction:testImage];
最佳答案
正如 amit3117 指出的那样,您应该使用委托(delegate)。该协议(protocol)至少应该使用一种方法来定义,该方法可以向委托(delegate)传达以模态方式呈现的 View Controller 已完成其工作的信息。
@class ViewController;
@protocol MyViewControllerDelegate <NSObject>
-(void)viewControllerDidFinish:(ViewController *)sender;
@end
编辑:我忘记添加您应该为 ViewController 的委托(delegate)提供一个公共(public)属性
@interface ViewController : UIViewController
@property (nonatomic, weak) id <MyViewControllerDelegate> delegate;
@end
您可以使用主视图 Controller 作为委托(delegate)。因此,在您的主视图 Controller 实现中,您还会有:
@interface MyMasterViewController () <MyViewControllerDelegate>
@end
@implementation MyMasterViewController
-(void)showViewController
{
m_ViewController = [[ViewController alloc] initWithNibName:@"ViewController"
bundle:nil];
m_ViewController.modalPresentationStyle = UIModalPresentationFormSheet;
m_ViewController.delegate = self;
// –presentModalViewController:animated: is deprecated!
[self.parentViewController presentViewController:m_ViewController
animated:YES
completion:nil];
}
-(void)viewControllerDidFinish:(ViewController *)sender
{
// Add any code you want to execute before dismissing the modal view controller
// –dismissModalViewController:animated: is deprecated!
[self.parentViewController dismissViewControllerAnimated:YES
completion:^{
// code you want to execute after dismissing the modal view controller
}];
}
@end
当m_ViewController
完成其工作时,它应该调用:
[self.delegate viewControllerDidFinish:self];
关于ios - 在 ipad 中关闭 ModalView 后调用 MasterView 中的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16413147/
在许多 iPhone 应用程序之后,我正在尝试我的第一个 iPad 应用程序。 当我加载 iPad 的 Master-Detail Application 模板时,当您按下 Bar Button 时,
我使用 tableView 创建了一个 MasterViewController 项目,现在我想向其中添加一些选项卡。我尝试将选项卡栏拖放到 MasterViewController 中并显示选项卡,
我希望 iPad 在纵向模式下仅显示 UISplitViewController 的主视图,在横向模式下同时显示主视图和详细 View ? 我应该怎么做? 系统为iOS 7。 最佳答案 根据我的经验,
我有一个包含 Master(显示表格 View )和 Details(显示详细数据)的 Split View。当我启动我的应用程序时,它首先显示没有数据的详细 View ,但我需要首先显示主视图。 我
我知道很多用户问过这个问题,但我没有找到与我的问题相关的任何答案。 我正在使用 UISplitViewController ,我的应用程序从登录页面开始,所以我在开始时隐藏了 masterView ,
我试图在 Storyboard中推送到详细 View ,但没有用。 -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sende
更新 我最终解决了 MGSplitViewController 的问题,所以我现在使用项目的这个分支:http://github.com/ArtSabintsev/MGSplitViewControl
我是 iOS 编程的新手(学习 Swift),最近对 Master Detail Applications 感兴趣,因为我正在学习的书的当前章节也是关于它的。 我注意到我的书似乎有点太旧了,因为 Xc
我有一个简单的 iPad 应用程序,其中包含带 TableView 的 MasterviewController 和包含 UIWebView 的 DetailViewController。然后我在 S
在详细 View Controller 中,我有表单列表。填写该表单后,我在单击“保存”按钮后将其存储到数组中,然后将该数组传递到 MasterView 并显示表单数。 最佳答案 你应该看看设计模式。
我正在从事一个项目,该项目是架构中的主从架构,它是一个通用应用程序。我的 DetailViewController 导航栏中有一个搜索控件。当我开始搜索时,同时如果我滑动/点击左栏按钮以显示 Mast
我已经在 Objective-C 中为 iPad 制作了一个应用程序。在此我正在解析一个 xml 文件并使用它在 MasterView(Split View App)中显示其内容。但是,xml 文件会
我需要在 UIViewController 的左侧部分添加一个 subview ,当 masterview 处于隐藏状态(纵向)时,它向用户显示屏幕左侧附近有一些东西。并且此 View 必须随 UIS
我正在使用 iPad 的主从模板。我有一个 ViewController,我想以模态方式显示它,所以我使用了这段代码 AppDelegate *appDelegate = (AppDelegate *
全部, 我在 iPad 的 IOS8 中遇到了新的 UISplitViewcontroller 问题。我在 detailViewcontroller 的 Storyboard 中有一个 UITable
我有一个 UITabBarController 应用程序,其中一个选项卡显示应用程序设置。这是一个带有多个细节 Controller 的 UISplitViewController,这些 Contro
我主要从事 iPhone 应用程序方面的工作。现在我需要构建一个 iPad 应用程序。因为我需要将 NavigationController 放在 iPad 的 Master Detail View
我是新手 我的xcode版本是11.2.1,swift是5.1.2 当我在MasterView中使用NavigationView时,我有两个DetailView 我想在第一个DetailView关闭时
更新 18/3 #2。我已经开始计算 beginUpdates 和 EndUpdates 以确保它们相等。就在出现异常之前,它们不同步。虽然不确定为什么。 18 月 3 日更新:我想我已经找到了问题,
我是一名优秀的程序员,十分优秀!