-1

これが私がやりたいことです。それが可能かどうかはわかりませんが、アプリストアで受け入れられるクリーンなコードで答えがあれば、私はそれに対して賞金を与えることができてうれしいです!

-MFMessageComposeViewControllerにカスタムアニメーションを表示します。(これはモーダルビューコントローラーです)。

-次に、このMFMessageComposeViewControllerをカスタムアニメーションでアニメーション化すると同時に、MFMessageComposeControllerの新しいインスタンスでアニメーション化します。(繰り返しますが、カスタムアニメーション)。

この質問のために、簡単にして、最初のMFMessageComposeViewControllerを右からスライドインし、次に(送信ボタンが押されたときに)左にスライドして、新しいインスタンスを右からスライドさせるとしましょう。 (navコントローラーのデフォルトのプッシュアニメーションとほとんど同じです)。

これが不可能な場合、これを行う方法がない理由の説明は素晴らしいでしょう:)

4

6 に答える 6

4

いいえ、しかし、あなたはあなたが望むように見えるトリックをすることができます.

- (IBAction)showComposer:(id)sender {
    // 1) get the prepared image of empty composer
    UIImageView *composerView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"preparedImage"]];
    composerView.frame = rightOffscreenFrame;
    [self.view addSubview:composerView];
    // 2) do any transitions, and transforms with it
    [UIView animateWithDuration:0.33 animations:^{
        composerView.frame = self.view.bounds;
    } completion:^(BOOL finished) {
        if (finished) {
            // 3) when it is time, just add a real composer without animation
            MFMailComposeViewController *composer = [[MFMailComposeViewController alloc] init];
            composer.mailComposeDelegate = self;
            [self presentViewController:composer animated:NO completion:^{
                [composerView removeFromSuperview];
            }];
        }
    }];

}

- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
    // 4) when user will send message, render the new image with content of composer
    UIGraphicsBeginImageContext(self.view.bounds.size);
    [controller.view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    UIImageView *composerView = [[UIImageView alloc] initWithImage:newImage];
    composerView.frame = self.view.bounds;
    // 5) show it below composer, close composer without animation.
    [self.view addSubview:composerView];
    [self dismissViewControllerAnimated:NO completion:^{
        // 6) do any transitions, and transforms with image.
        [UIView animateWithDuration:0.33 animations:^{
            composerView.frame = leftOffscreenFrame
        } completion:^(BOOL finished) {
            if (finished) {
                [composerView removeFromSuperview];
            }
        }];
    }];
}
于 2012-10-14T08:32:18.647 に答える
3

ええと、あなたはこれで私の好奇心を真剣に捉えたと言わざるを得ません。さて、あなたの質問に関する限り、これについてできることはそれほど多くないようです。

私は作曲家をデフォルト以外のスタイルで表現しようとして、いくつかの異なるアプローチを取りましたが、ほとんど成功しませんでした。私が得ることができた最も近いものはこれでした:

UIViewAnimationTransition trans = UIViewAnimationTransitionCurlDown;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationTransition:trans forView:[self view] cache:YES];
[self presentViewController:controller animated:NO completion:nil];
[UIView commitAnimations];

このプレゼンテーション方法を使用すると、アニメーション効果が発生しましたが、実際には作曲者には適用されないようでした. 白紙のページをめくるだけでした。また、アルファなどのトランジション効果を手動で追加し、作曲家のビュー プロパティに直接調整を加えようとしましたが、それもあまり効果がありませんでした。

すべてがこれに沸騰し続けました:

重要: メッセージ作成インターフェース自体はカスタマイズできないため、アプリケーションで変更しないでください。さらに、インターフェイスを表示した後、アプリケーションは SMS コンテンツにそれ以上の変更を加えることができません。ユーザーはインターフェイスを使用してコンテンツを編集できますが、プログラムによる変更は無視されます。したがって、必要に応じて、インターフェイスを表示する前にコンテンツ フィールドの値を設定する必要があります。

編集:実際、私はこれを機能させる方法を見つけたかもしれないと思います。あらゆる種類のカスタム トランジションを使用できる可能性はまだ低いと思われます。また、Apple がこれを承認するとは約束できませんが、これにより、composer ナビゲーション コントローラーのプッシュ スタイルを提示できるはずです!

使用する代わりに:

[self presentViewController:controller animated:YES completion:nil];

使用する:

[self.navigationController pushViewController:[[controller viewControllers] lastObject] animated:YES];

これにより、実際に作曲家にプッシュすることができます。デフォルトでは、この動作はサポートされておらず、ナビゲーション コントローラー (コンポーザー) にプッシュできないというエラーが発生します

- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result次に、単純に使用してフォローアップします。

[self.navigationController popToRootViewControllerAnimated:YES];

それ以外の:

[self dismissViewControllerAnimated:YES completion:nil];

編集 2:申し訳ありませんが、質問のポイントの 1 つを忘れていたようです。コンポーザーの 1 つのインスタンスから別のインスタンスにプッシュする場合は、コンポーザーごとに iVar を作成し、それらを viewDidLoad で設定してから、didFinishWithResult. ただし、これは問題を部分的にしか解決しません。現状では、以下に投稿したコードは問題なく機能しますが、バックアップはうまくいきません。この理由は、メッセージが正常に送信された後、作曲家が閉じられて nil になることを期待しているためであり、その結果、キャンセルは自動的に無効になるためだと思います。

全体として、少しいじっても、これを機能させることができるはずです。

 - (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {

    switch (result) {
        case MessageComposeResultCancelled:
            if (controller == firstComposer) {
                [self.navigationController popToRootViewControllerAnimated:YES];
            }
            else if (controller == secondComposer) {
                [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:1] animated:YES];
            }

            break;
        case MessageComposeResultFailed:
            NSLog(@"Failed");
            break;
        case MessageComposeResultSent:

            if (controller == firstComposer) {
                [self.navigationController pushViewController:[[secondComposer viewControllers] lastObject] animated:YES];
                [secondComposer becomeFirstResponder];
            }
            break;
        default:
            break;
    }
}

これを作成したプロジェクトをダウンロードするためのリンク。

于 2012-10-12T23:05:45.460 に答える
0

Appleから提供されたカスタムコンポーネントであるため、可能ではないと思います

于 2012-10-11T05:32:51.997 に答える
0

モーダル ビューとしてのMFMailComposeViewControllerは、Apple の HIG と一致しています。ナビゲーションスタックにプッシュすることはできません。使用する :

-presentModalViewController:animated:

-presentViewController:animated:completion` (if supporting iOS 5).

本当に必要な場合は、modalTransitionStyleを使用してください

mail.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal; 
mail.modalTransitionStyle=UIModalTransitionStyleCoverVertical;
mail.modalTransitionStyle = UIModalTransitionStylePartialCurl; 
mail.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

modalPresentationStyleも使用します。

FMailComposeViewController は UINavigationController であり、ナビゲーション コントローラーのプッシュはサポートされていません。

于 2012-10-10T11:05:28.713 に答える
-1

その可能性と、私が使用したアプリの 1 つで、通常の ViewController として使用できます。

もう 1 つ、開発者はメール コンポーザを表示する方法と、それを閉じる方法を決定します。

iOS/Apple ではなく、当社が処理するプレゼンテーションと却下..

于 2012-10-04T06:22:03.583 に答える