iPhone 模态视图

发布于 2024-11-09 14:24:58 字数 2090 浏览 0 评论 0原文

我有第一个控制器 (itemDetailViewController) :

- (void)loadView {
    CGRect frame = CGRectMake(10, 10, 300, 300);

    item1DetailView = [[Item1DetailView alloc] initWithFrame:frame andController:self];
    self.view = item1DetailView;
    [item1DetailView release];
}

// there is a button in my view : item1DetailView to call this method :
- (void)clickOnButtonToModalView:(id)sender{
    Item1DetailModalViewController *item1DetailModalViewController = [[Item1DetailModalViewController alloc] init];
    item1DetailModalViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentModalViewController:item1DetailModalViewController animated:YES];
    [item1DetailModalViewController release];
}

在我的第二个控制器 (item1DetailModalViewController) 中,我有一个 dismissModalViewController 按钮:

- (void)clickOnButtonSortirModalView:(id)sender{
    [self dismissModalViewControllerAnimated:YES];
}

item1DetailModalViewController 已关闭,但 item1DetailView 填满了屏幕。框架是: CGRect frame = CGRectMake(10, 10, 300, 300);

我缺少什么吗?

我已经尝试过:

在我的模态视图控制器中:

@protocol Item1DetailModalViewDelegate
- (void)modalViewControllerDone;
@end
@interface Item1DetailModalViewController : UIViewController {
    Item1DetailModalView *item1DetailModalView;
    id <Item1DetailModalViewDelegate> delegate;
}
@property (nonatomic, retain) Item1DetailModalView *item1DetailModalView;
@property (nonatomic, assign) id <Item1DetailModalViewDelegate> delegate;
- (void)clickOnButtonSortirModalView:(id)sender;
@end

- (void)clickOnButtonSortirModalView:(id)sender{
    //[self dismissModalViewControllerAnimated:YES];
    [self.delegate modalViewControllerDone];
}

In my itemDetailViewController :
@interface Item1DetailViewController : UIViewController <Item1DetailModalViewDelegate>

- (void)modalViewControllerDone {
    [self dismissModalViewControllerAnimated:YES];
}

但是问题已经存在......

谢谢您的帮助!

I have a first controller (itemDetailViewController) :

- (void)loadView {
    CGRect frame = CGRectMake(10, 10, 300, 300);

    item1DetailView = [[Item1DetailView alloc] initWithFrame:frame andController:self];
    self.view = item1DetailView;
    [item1DetailView release];
}

// there is a button in my view : item1DetailView to call this method :
- (void)clickOnButtonToModalView:(id)sender{
    Item1DetailModalViewController *item1DetailModalViewController = [[Item1DetailModalViewController alloc] init];
    item1DetailModalViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentModalViewController:item1DetailModalViewController animated:YES];
    [item1DetailModalViewController release];
}

In my second controller (item1DetailModalViewController) I've got a button for dismissModalViewController :

- (void)clickOnButtonSortirModalView:(id)sender{
    [self dismissModalViewControllerAnimated:YES];
}

item1DetailModalViewController is close but item1DetailView fills the screen. The frame was : CGRect frame = CGRectMake(10, 10, 300, 300);

Is there something I am missing?

I have tried this :

in my modal view controller :

@protocol Item1DetailModalViewDelegate
- (void)modalViewControllerDone;
@end
@interface Item1DetailModalViewController : UIViewController {
    Item1DetailModalView *item1DetailModalView;
    id <Item1DetailModalViewDelegate> delegate;
}
@property (nonatomic, retain) Item1DetailModalView *item1DetailModalView;
@property (nonatomic, assign) id <Item1DetailModalViewDelegate> delegate;
- (void)clickOnButtonSortirModalView:(id)sender;
@end

- (void)clickOnButtonSortirModalView:(id)sender{
    //[self dismissModalViewControllerAnimated:YES];
    [self.delegate modalViewControllerDone];
}

In my itemDetailViewController :
@interface Item1DetailViewController : UIViewController <Item1DetailModalViewDelegate>

- (void)modalViewControllerDone {
    [self dismissModalViewControllerAnimated:YES];
}

But the problem is already exist ...

Thank you for your Help !

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

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

发布评论

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

评论(1

十级心震 2024-11-16 14:24:58

missModalViewController 必须由呈现视图 1 的控制器调用。在您的例子中,它是 itemDetaiViewController

您需要做的是将 itemDetailViewController 作为委托添加到模式视图控制器。然后,当您点击按钮时,您将可以调用:

- (void)clickOnButtonSortirModalView:(id)sender{
    [delegate modalViewControllerDone];
}

并在 itemDetailViewController 中:

- (void)modalViewControllerDone {
  [self dismissModalViewControllerAnimated:YES];
}

dismissModalViewController must be called by the controller presenting the view 1. In your case, it's itemDetaiViewController.

What you need to do is add your itemDetailViewController as a delegate to the modal view controller. Then when you tap on the button, this will allow you to call:

- (void)clickOnButtonSortirModalView:(id)sender{
    [delegate modalViewControllerDone];
}

and in itemDetailViewController:

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