【发布时间】:2013-12-19 17:30:38
【问题描述】:
我有一个自定义导航栏,其中包含所有视图的通用图像。此外,我还有一个 MFMailComposer 视图,但我没有在此处获得带有发送和取消按钮的默认导航栏。我试图从导航栏中删除图像.但不工作。这是我尝试过的:
-(void)mailShare:(id)sender{
[self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
if (mailClass != nil) {
//[self displayMailComposerSheet];
// We must always check whether the current device is configured for sending emails
if ([mailClass canSendMail])
{
[self applyComposerInterfaceApperance];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Device not configured to send mail" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
alert = nil;
return;
}
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Device not configured to send mail" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
alert = nil;
return;
}
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
// [ picker.navigationBar setTintColor:[UIColor greenColor]];
[picker setSubject:@"Try this Pack from FORCE PACKS"];
CGRect rect = CGRectMake(0, 44, 320, 440);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[self.view.layer renderInContext:context];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// Attach an image to the email
NSData *myData = UIImagePNGRepresentation(img);
[picker addAttachmentData:myData mimeType:@"image/jpeg" fileName:@"rainy"];
// Fill out the email body text
NSString *emailBody = @"I'm on the road to recovery! Check out my latest Exercise Log from FORCE Packs";
[picker setMessageBody:emailBody isHTML:NO];
[self presentViewController:picker animated:YES completion:nil];
myData = nil;
}
【问题讨论】:
-
能否添加用于自定义导航栏的代码?
-
@Clever 错误肯定。这是代码:[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navBar.png"] forBarMetrics:UIBarMetricsDefault];
标签: ios uinavigationcontroller custom-controls objective-c-blocks