私のアプリでは、電子メールIDがコース外のテキスト形式で書かれている必要がありますが、そのテキストはクリック可能でなければなりません。クリックすると、2 つのフィールドと 2 つのボタンを含むポップアップが表示されます。2 つのフィールドは、「送信者」と「メッセージ本文」を入力できるように編集可能にする必要があります。2 つのボタンは送信とキャンセルです。助けてください。
1 に答える
0
メールアドレスでボタンを作成し、次のようにセレクターを設定するだけです...
UIButton *BtnEmail = [UIButton buttonWithType:UIButtonTypeCustom];
[BtnEmail setBackgroundColor:[UIColor clearColor]];
[BtnEmail setTitle:@"YourEmailId" forState:UIControlStateNormal];
BtnEmail.frame = CGRectMake(85, 100, 150, 39 );/// set your frame
[BtnEmail addTarget:self action:@selector(EmailButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:BtnEmail];
.h
アクションイベント(メソッド)でこのコードを記述します..これら2つのデリゲートをファイルMFMessageComposeViewControllerDelegate
に追加するだけで、MFMailComposeViewControllerDelegate
1つのフレームワーク名も MessageUI.framework
-(IBAction)EmailButtonClicked:(id)sender{
if ([MFMailComposeViewController canSendMail]) {
appDelegate.imgCapture = [self captureView];
[appDelegate.imgCapture retain];
MFMailComposeViewController *mailComposeViewController = [[MFMailComposeViewController alloc] init];
NSString *mailBody = @"Set Your Body Message";
[mailComposeViewController setMessageBody:mailBody isHTML:NO];
mailComposeViewController.mailComposeDelegate = self;
[self presentViewController:mailComposeViewController animated:YES completion:nil];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"e-Mail Sending Alert"
message:@"You can't send a mail"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
}
これらの以下のメソッドはデリゲートメソッドです..
#pragma mark - MFMessage Delegate
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
[self dismissViewControllerAnimated:YES completion:nil];
}
これがお役に立てば幸いです...
于 2012-11-29T10:04:52.013 に答える