0

我正在使用我忍受的模态视图中的按钮单击:

UIAlertView *   alert =
    [[UIAlertView alloc] initWithTitle: title
                               message: reason
                              delegate: self
                     cancelButtonTitle: @"New"
                     otherButtonTitles: @"View", nil];
    [alert show];

当点击下面的“clickedButtonAtIndex”方法中的“查看”按钮时,我调用了“[self performSegueWithIdentifier:@"ModalSaleDetail1" sender:self];"

- (void) alertView: (UIAlertView *) alertView clickedButtonAtIndex: (NSInteger) buttonIndex
{
    if ([alertView.title isEqualToString: @"Successful"]) {
        switch (buttonIndex) {
            case 0:     //  New transaction
            {
                if ([self.currentSale.lastStatus isEqualToString:@"approved"]) {
                    [self displayComposerSheet];
                }
                [self clearTransaction:nil];
                break;
            }
            case 1:     //  View Transaction Details
            {
                NSLog(@"User wants to view transaction details.");
                self.currentSale.cardNumber = self.currentSale.cardNumber.bulletRedacted;
                self.cardNumberField.text = self.displayCardNumberView.text = self.currentSale.cardNumber;

                if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {  // device is iPad
                    self.tabBarController.selectedViewController = [self.tabBarController.viewControllers objectAtIndex:1];
                    UISplitViewController *splitVC = (UISplitViewController *)(self.tabBarController.selectedViewController);
                    UINavigationController *navC = [[splitVC viewControllers] lastObject];
                    APSaleDetailViewController *salesDVC = (APSaleDetailViewController *)navC.topViewController;
                    // If came here from new sale set to self.currentSale, otherwise do not
                    if (!salesDVC.currentSale) {
                        salesDVC.currentSale = self.currentSale;
                    }
                    salesDVC.apNewTVC = self;
                    if ([self.currentSale.lastStatus isEqualToString:@"approved"]) {
                        [self displayComposerSheet];
                    }
                } else {                                                                        // device is iPhone
                    if ([self.currentSale.lastStatus isEqualToString:@"approved"]) {
                        [self displayComposerSheet];
                    }
                    [self performSegueWithIdentifier:@"ModalSaleDetail1" sender:self];
                }
                break;
            }
            default:
            {
                NSAssert1(NO, @"Unknown alert button %d", buttonIndex);
            }
        }
    } else if .....

在我使用 MFMailComposeViewController 实现我的电子邮件发件人之前,这个 segue 工作得很好。

我使用以下代码显示 MFMailComposeViewController 的模式视图:

// Displays an email composition interface. Populates all the Mail fields.
-(void)displayComposerSheet
{
    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
    picker.mailComposeDelegate = self;

    [picker setSubject:@"Receipt for credit card transaction"];

    // Set up recipients
    NSArray *toRecipients = [NSArray arrayWithObject:self.currentSale.emailAddress];

    [picker setToRecipients:toRecipients];

    UIGraphicsBeginImageContext(self.view.frame.size);
    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    NSData * imageData = UIImageJPEGRepresentation(image, 1.0);

    if ( [MFMailComposeViewController canSendMail] ) {
        NSString *emailBody = @"Your credit card transaction summary and signature:";
        [picker setMessageBody:emailBody isHTML:NO];
        [picker addAttachmentData:imageData mimeType:@"image/jpeg" fileName:@"attachment"];
        NSData *myData = UIImagePNGRepresentation(self.signatureImage);
        [picker addAttachmentData:myData mimeType:@"image/png" fileName:@"Autograph"];
        [self presentModalViewController:picker animated:YES];
    }
}

现在,当 [self performSegueWithIdentifier:@"ModalSaleDetail1" sender:self] 在刚刚调用 [self displayComposerSheet] 之后被调用时,不会发生 segue。电子邮件作曲家表正确显示,但在我发送或取消它后,segue 不会发生。如果我注释掉对 [self displayComposerSheet] 的调用,segue 就会发生(但当然没有电子邮件)。

顺便说一句,iPad 代码与 [self displayComposerSheet] 调用配合得很好,因为它不使用 segue。

在呈现模态对话框后立即执行转场是否正常工作?

我正在为 iOS 6.1 构建 Xcode 4.6 并部署到 iOS 5.1。我的 iPhone 运行 5.1.1,我的 iPad 运行 6.1。

4

2 回答 2

0

我知道,这并不能解决您使用 Segues 的问题,但如果您尝试返回到以前的视图控制器,请尝试以下操作:

[self dismissViewControllerAnimated:YES completion:nil];
于 2014-03-22T14:14:56.813 回答
0
  • (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender NS_AVAILABLE_IOS(5_0);

你看,这个接口在 iOS 5 中是不可用的

于 2013-02-05T07:35:15.840 回答