missModalViewController 无法正常工作

发布于 2024-11-16 13:24:58 字数 916 浏览 3 评论 0原文

我的应用程序处于工作状态,但由于某种原因,当我在关闭模态视图控制器时收到内存警告时,我的应用程序会转到 viewDidUnload 。我已经检查了所有代码,但找不到原因。

在我的应用程序中没有 UINavigationController。

MainView 的代码:

-(void) showInfo:(id) sender
{

  PhotoFeatureViewController *photoGalleryViewController = [[PhotoFeatureViewController alloc] initWithNibName:@"PhotoFeatureViewController" bundle:nil];

  photoGalleryViewController.modalPresentationStyle = UIModalPresentationFullScreen;
  photoGalleryViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
  [photoGalleryViewController loadPhotogalleryImages:[itemTagArray objectAtIndex:[detailInfoBtn tag]]];


  [self presentModalViewController:photoGalleryViewController animated:YES];
  [photoGalleryViewController release];
}

ModalView 的代码:

-(IBAction) dismiss
{

  [self.parentViewController dismissModalViewControllerAnimated:YES];

}

My app is in working condition but for some reason my app goes to viewDidUnload when I receive memory warning while dismissing modal view controller. I've been through all my code and cannot find a reason for this.

In my app there is no UINavigationController.

code for MainView :

-(void) showInfo:(id) sender
{

  PhotoFeatureViewController *photoGalleryViewController = [[PhotoFeatureViewController alloc] initWithNibName:@"PhotoFeatureViewController" bundle:nil];

  photoGalleryViewController.modalPresentationStyle = UIModalPresentationFullScreen;
  photoGalleryViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
  [photoGalleryViewController loadPhotogalleryImages:[itemTagArray objectAtIndex:[detailInfoBtn tag]]];


  [self presentModalViewController:photoGalleryViewController animated:YES];
  [photoGalleryViewController release];
}

code for ModalView :

-(IBAction) dismiss
{

  [self.parentViewController dismissModalViewControllerAnimated:YES];

}

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

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

发布评论

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

评论(5

橘香 2024-11-23 13:24:58

在解雇中,尝试:

[self dismissModalViewControllerAnimated:YES];

In dismiss, try:

[self dismissModalViewControllerAnimated:YES];
若言繁花未落 2024-11-23 13:24:58

试试这个

-(IBAction) dismiss 
{
    [self dismissModalViewControllerAnimated:TRUE];
}

Try out this

-(IBAction) dismiss 
{
    [self dismissModalViewControllerAnimated:TRUE];
}
荒芜了季节 2024-11-23 13:24:58

在 photoGalleryViewController 中添加关闭功能。
并像下面这样使用它:

-(IBAction) dismiss {
    [self dismissModalViewControllerAnimated:YES];
}

Add dismiss function inside photoGalleryViewController.
And use it like below:

-(IBAction) dismiss {
    [self dismissModalViewControllerAnimated:YES];
}
哆兒滾 2024-11-23 13:24:58

你已经得到答案了:-

[selfmissModalViewControllerAnimated:TRUE];

you already got the answer:-

[self dismissModalViewControllerAnimated:TRUE];

心欲静而疯不止 2024-11-23 13:24:58

您是否知道 Apple 文档建议使用带有 ModalViewController 的委托?如果您仍然遇到问题,这样的不同方法可能会有所帮助:

基本上,您为以模态方式呈现的视图控制器(即 photoGalleryViewController)定义一个委托属性,并在创建 photoGalleryViewController 并以模态方式呈现它时将其设置为父视图控制器。在miss{}中,您将使用delegate(parent)来调用处理dismissModalViewController的方法。

它需要为 photoGalleryViewController 设置一个协议,并将协议和委托方法添加到父视图控制器的定义中,但这些额外的步骤并不费力,从长远来看,更好的设计可能会带来回报。

Apple 文档 - 视图控制器程序员指南 http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/ModalViewControllers/ModalViewControllers.html#//apple_ref/doc/uid/TP40007457-CH111-SW14

关于设置模态视图的建议使用委托的控制器:
呈现模态视图控制器

Did you know that the Apple docs recommend using a delegate with a ModalViewController? If you're still having trouble a different approach like this might help:

Basically, you define a delegate property for the view controller that's being presented modally (i.e photoGalleryViewController) and set it to the parent view controller when you create photoGalleryViewController and present it modally. In dismiss{}, you would use the delegate(parent) to call a method that handles dismissModalViewController.

It requires setting up a protocol for photoGalleryViewController and adding the protocol and the delegate method to the parent view controller's definition, but those extra steps aren't much effort and the better design would probably payoff in the long run.

Apple Doc - View Controller Programmers Guide http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/ModalViewControllers/ModalViewControllers.html#//apple_ref/doc/uid/TP40007457-CH111-SW14

advice on setting modal view controllers using delegates:
present modal view controller

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