完成按钮不会关闭 modalviewcontroller
当我单击“完成”按钮时,它不会关闭 modalviewcontroller 在我的情况下它是 infoviewcontroller。我是否应该在 mainviewcontroller h 和 m 文件中添加一些内容?
在 Infoviewcontroller.h 中
#import <UIKit/UIKit.h>
@protocol ModalViewDelegate <NSObject>
-(void) dismissModalView;
@end
@interface Infoviewcontroller : UIViewController <UITextViewDelegate>
{
id<ModalViewDelegate>dismissDelegate;
UITextView *textView;
UINavigationBar *navBar;
}
@property (nonatomic, retain) UITextView *textView;
@property (nonatomic, assign) UINavigationBar *navBar;
@property (nonatomic, assign) id<ModalViewDelegate>dismissDelegate;
@end
在 Infoviewcontroller.m 中
#import "Infoviewcontroller.h"
#import <QuartzCore/QuartzCore.h>
@implementation Infoviewcontroller
@synthesize textView;
@synthesize navBar;
@synthesize dismissDelegate;
-(void)dealloc
{
[textView release];
[navBar release];
[super dealloc];
}
- (void) viewDidLoad
{
[super viewDidLoad];
UIButton* backButton = [UIButton buttonWithType:101];
[backButton addTarget:self action:@selector(dismissView:) forControlEvents:UIControlEventTouchUpInside];
[backButton setTitle:@"Done" forState:UIControlStateNormal];
// create button item
UIBarButtonItem* backItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
// add the button to navigation bar
self.navigationItem.leftBarButtonItem = backItem;
[backItem release];
-(void)dismissView:(id)sender
{
//Make the delegate close the modal
[self.dismissDelegate dismissModalView];
}
当我单击“完成”按钮时,它不会关闭 modalviewcontroller 在我的情况下它是 infoviewcontroller。我是否应该在 mainviewcontroller h 和 m 文件中添加一些内容?如果我在 mainviewcontroller 文件中遗漏了某些内容,请帮助我。
感谢您的帮助,
When i click on the done button it is not dismissing modalviewcontroller in my case it is infoviewcontroller. Am i supposed to add something in mainviewcontroller h and m file.
In the Infoviewcontroller.h
#import <UIKit/UIKit.h>
@protocol ModalViewDelegate <NSObject>
-(void) dismissModalView;
@end
@interface Infoviewcontroller : UIViewController <UITextViewDelegate>
{
id<ModalViewDelegate>dismissDelegate;
UITextView *textView;
UINavigationBar *navBar;
}
@property (nonatomic, retain) UITextView *textView;
@property (nonatomic, assign) UINavigationBar *navBar;
@property (nonatomic, assign) id<ModalViewDelegate>dismissDelegate;
@end
In the Infoviewcontroller.m
#import "Infoviewcontroller.h"
#import <QuartzCore/QuartzCore.h>
@implementation Infoviewcontroller
@synthesize textView;
@synthesize navBar;
@synthesize dismissDelegate;
-(void)dealloc
{
[textView release];
[navBar release];
[super dealloc];
}
- (void) viewDidLoad
{
[super viewDidLoad];
UIButton* backButton = [UIButton buttonWithType:101];
[backButton addTarget:self action:@selector(dismissView:) forControlEvents:UIControlEventTouchUpInside];
[backButton setTitle:@"Done" forState:UIControlStateNormal];
// create button item
UIBarButtonItem* backItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
// add the button to navigation bar
self.navigationItem.leftBarButtonItem = backItem;
[backItem release];
-(void)dismissView:(id)sender
{
//Make the delegate close the modal
[self.dismissDelegate dismissModalView];
}
When i click on the done button it is not dismissing modalviewcontroller in my case it is infoviewcontroller. Am i supposed to add something in mainviewcontroller h and m file. Please help me if i am missing some thing in the mainviewcontroller files.
Thanks for help,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
但是如果你想在委托方法中关闭控制器,那么你首先必须在 infoviewController 中设置委托,然后在委托方法中使用 infoviewController 对象来关闭它。
but if you want to dismiss the controller in the delegate method then you first have to set the delegate in infoviewController then in the delegate method use the infoviewController object to dismiss it .