//插入
mailPicker = [[MFMailComposeViewControlleralloc] init];
mailPicker.view.frame = [UIScreenmainScreen].bounds;
window = [[UIWindowalloc] initWithFrame: [[UIScreenmainScreen] bounds]];
if ( [[UIDevicecurrentDevice].systemVersionfloatValue] < 6.0)
{
// warning: addSubView doesn't work on iOS6
[window addSubview: mailPicker.view];
}
else
{
// use this method on ios6
window.rootViewController =self;
[windowsetRootViewController:self];
}
[windowmakeKeyAndVisible];
//移除
//add的时候是分版本的,所以这里也是分版本,否则crash
if ( [[UIDevicecurrentDevice].systemVersionfloatValue] < 6.0)
{
[mailPicker.viewremoveFromSuperview];
}
else
{
[mailPickerdismissModalViewControllerAnimated:YES];
}
[mailPicker release];
mailPicker = nil;
[selfremoveFromParentViewController];
[self release];
[windowremoveFromSuperview];
[window release];