单击选项卡在 iPhone 中打开电子邮件视图
嗨,
我是 iPhone 开发新手。我以编程方式创建了选项卡栏,并在选项卡栏中设置了五个视图。现在我想在单击选项卡栏时加载电子邮件应用程序视图。这工作正常。当我单击下一个选项卡栏并返回到电子邮件视图时,我能够看到正常视图,而不是电子邮件视图。只有一次我能够看到我的邮件应用程序。我在 viewDidLoad 方法中有邮件应用程序。所以请指导我。
这是我的代码,
- (void)viewDidLoad {
[super viewDidLoad];
MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
mail.mailComposeDelegate = self;
if ([MFMailComposeViewController canSendMail]) {
[mail setToRecipients:[NSArray arrayWithObjects:@"[email protected]",nil]];
[mail setSubject:@"Title"];
[self presentModalViewController:mail animated:NO];
}
[mail release];
}
谢谢。
HI,
I am new to iphone development.I have created the tabbar programmatically and sets five views in the tabbar. Now i want to load an email application view when i clicked the tabbar.This works properly.When i clicked the next tabbar and come back to the email view, i am able to see the normal view and not the Email view.Only one time i am able to see my mail application.I have mail application in the viewDidLoad method. So please guide me.
Here is my code,
- (void)viewDidLoad {
[super viewDidLoad];
MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
mail.mailComposeDelegate = self;
if ([MFMailComposeViewController canSendMail]) {
[mail setToRecipients:[NSArray arrayWithObjects:@"[email protected]",nil]];
[mail setSubject:@"Title"];
[self presentModalViewController:mail animated:NO];
}
[mail release];
}
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
viewDidLoad 仅在 nib 文件加载后运行,即第一次显示 viewController 时运行,然后在发送任何内存警告后运行一次。
您想使用 viewDidAppear: 来代替,每次 viewController 进入视图后都会调用它。
viewDidLoad
only runs after the nib file has been loaded, which is once the first time the viewController is shown and then once after any memory warnings are sent.You want to use
viewDidAppear:
instead which is called every time after the viewController comes into view.如果您使用 viewDidAppear 方法,它将继续调用邮件视图。因此,请使用 viewWillAppear 方法。
If you use viewDidAppear method it will be keep on calling the mail view.So use viewWillAppear method.