iPhone 模态视图
我有第一个控制器 (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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
missModalViewController 必须由呈现视图 1 的控制器调用。在您的例子中,它是
itemDetaiViewController
。您需要做的是将 itemDetailViewController 作为委托添加到模式视图控制器。然后,当您点击按钮时,您将可以调用:
并在
itemDetailViewController
中: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:
and in
itemDetailViewController
: