iphone - 从 subview 使用 presentModalViewController

标签 iphone objective-c ios ipad uiviewcontroller

我想在 subview 中使用 presentModalViewController 方法,但它对我不起作用 这是我的代码:

subview :

-(IBAction) PressMoyensEs {
    MoyensEstimatifsViewController *MoyE = [[MoyensEstimatifsViewController alloc] initWithNibName:@"MoyensEstimatifsViewController" bundle:nil];
    [self.parentViewController presentModalViewController:MoyE animated:YES];
}

最佳答案

你检查过你的self.parentViewController了吗?它很可能是 nil,在许多情况下都是如此,因此您的代码会悄无声息地失败。

而且,您是否尝试过 [self presentModalViewController:MoyE animated:YES];?它不太“正确”,但如果有效,则已经排除了一些失败原因。

关于iphone - 从 subview 使用 presentModalViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7121263/

相关文章:

objective-c - 如何在 Objective-C 中引发事件

iphone - 求一个使用GData API解析xml和获取属性的示例代码

objective-c - 设置声音输出/输入

ios - 在 iOS 中收到 APNS 时打开 View Controller

objective-c - 我是否必须发布以这种方式生成的深度复制的 NSMutableDictionary?

ios - Swift - 在分页时添加加载单元

iPhone - 在导航堆栈中将数据从子级传递给父级

ios - swift 4 "This class is not key value coding compliant"

ios - Xcode Main.storyboard 不显示 iOS 模拟器中出现的内容

iphone - 在 iOS5 中,我在图库中切换图片的方法很糟糕