Hi everyone.
I’m beggining to experiment with native code in IOS I have succeed in adding an ImageView over my unity view, by simply doing this in my AppController:
UIImageView *myImage = [[UIImageView alloc] initWithFrame: _window.frame];
[myImage setImage:[UIImage imageNamed:@“test.png”]];
[_window insertSubview:myImage atIndex:[_window.subviews count]];
//[_window addSubview:myImage];
[myImage release];
But now i’m trying to send a mail, and after creating and adding the view with the next code it never appears:
MailHandler *mailDelegateObject= nil;
mailDelegateObject = [[MailHandler alloc] init];
[_window insertSubview:mailDelegateObject.view atIndex:[_window.subviews
count]];
Here’s the code of my delegate for mail:
//MailHandler.h
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <MessageUI/MessageUI.h>
#import <MessageUI/MFMailComposeViewController.h>
@interface MailHandler : UIViewController {
//@interface MFMailComposeViewControllerDelegate : NSObject {
IBOutlet UIButton *button;
}
- (IBAction)actionEmailComposer;
@end
And the .mm:
// MailHandler.mm
#import “MailHandler.h”
//@implementation MFMailComposeViewControllerDelegate
@implementation MailHandler
-
(void)dealloc {
[super dealloc];
} -
(id)init
{
self = [super init];
NSLog(@“starts mailhandler”);
return self;
} -
(IBAction)actionEmailComposer {
if ([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
mailViewController.mailComposeDelegate = self;
[mailViewController setSubject:@“Subject Goes Here.”];
[mailViewController setMessageBody:@“Your message goes here.” isHTML:NO];
[self presentModalViewController:mailViewController animated:YES];
[mailViewController release];
}
else {
NSLog(@“Device is unable to send email in its current state.”);
}
}
- (void)viewDidLoad {
//[super viewDidLoad];
if ([MFMailComposeViewController canSendMail])
button.enabled = YES;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (void)viewDidUnload {
}
-(void)mailComposeController: (MFMailComposeViewController*)controller didFinishWithResult: (MFMailComposeResult)result error: (NSError*)error {
[self becomeFirstResponder];
[self dismissModalViewControllerAnimated:YES];
}
@end
Any help and suggestion is much appreciated, thanks !
Additionally, this is a correct approach to working with Unity and Xcode ?, by creating and adding/removing views whenever it’s needed ?, or there is any other better approach.
Edit: Problem solved.