在iOS 8 / Xcode 6中,UIPopoverController无法关闭

4

我的一个应用在iOS 7上运行良好,其中包含一个UIPopoverController,当用户在其外部点击时被解散。

UIPopoverController *myPopover = [[UIPopoverController alloc] initWithContentViewController:_myVC];
myPopover.popoverContentSize = CGSizeMake(300.0, 600.0);
[myPopover presentPopoverFromRect:sender.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

当我在iOS 8上运行我的应用程序时,没有崩溃,但是当我尝试通过点击外部区域退出弹出窗口时,会出现一个错误消息,内容如下:
attempt to dismiss modal view controller whose view does not currently appear.

控制台还告诉我:modalViewController = _myVC...

iOS 8中我无法退出我的弹出窗口!

有什么想法吗?

使用_myVC代码进行更新:

@protocol MyVCDelegate <NSObject>
@optional
- (void)myVCDoneProc:(NSURL *)sender;
- (void)calculateFileLengthConvolve;
- (void)checkConvolveTime;
@end

@interface MyVC: UIViewController <FirstDelegate, SecondDelegate>
{
    UIImageView                 *mDimView;
    UIActivityIndicatorView     *mSpinner;
    IBOutlet UISlider           *mMixSlider;
    IBOutlet UILabel            *mTimeWarningLabel;
    IBOutlet UIButton           *mButton;
}

@property (nonatomic, weak) AudioFilesViewController *AFVC;
@property (nonatomic, strong) IBOutlet UIView *view;
@property (nonatomic, assign) id<UnivConvolutionViewControllerDelegate>delegate;
@property NSString *filePath;


- (void)calculateFileLength;
- (IBAction)process;
- (IBAction)play:(UIButton *)sender;
- (IBAction)stop:(UIButton *)sender;
- (void)checkConvolveTime;

@end

@interface myVC () <UITableViewDelegate, UITableViewDataSource>
@end
@implementation myVC
{
    IBOutlet UITableView        *mImpulsesTableView;
    NSArray                     *mImpulses;
    NSString                    *irPath;
    NSArray                     *userImpulses;
}

@synthesize AFVC = _AFVC;
@synthesize view;
@synthesize delegate;
@synthesize filePath = mFilePath;

- (void)init {
    if(self = [super init]) {
        [[NSBundle mainBundle] loadNibNamed:@"MyVC" owner:self options:nil];

        // create mImpulses
        // set button titles and font, other init... etc.

    }
}

#pragma mark behavior - class methods
// The only view code is in:
- (void)process {
        if (mDimView == nil) {
        mDimView = [[UIImageView alloc] initWithImage:[DimmingImage dimmingImageWithSize:self.view.bounds.size]];
        mDimView.userInteractionEnabled = YES;
        mSpinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
        mSpinner.hidesWhenStopped = YES;
        [mDimView addSubview:mSpinner];
        mSpinner.center = CGPointMake(mDimView.bounds.size.width/2.0f,
                                      mDimView.bounds.size.height/2.0f);
    }

    mDimView.alpha = 0.0f;
    [self.view addSubview:mDimView];
    [UIView animateWithDuration:0.35f animations:^{
        mDimView.alpha = 0.7f;

    } completion:^(BOOL finished) {
        [mSpinner startAnimating];
    }];
}

#pragma mark FirstDelegate & Second Delegate

// FirstDelegate method to remove subviews when processing is complete
- (void)hideActivityView
{
    dispatch_async(dispatch_get_main_queue(), ^{

        [mSpinner stopAnimating];
        [UIView animateWithDuration:0.35f animations:^{
        mDimView.alpha = 0.0f;

    } completion:^(BOOL finished) {
        [mDimView removeFromSuperview];
        }];
    });
}

#pragma mark UITableViewDelegate & DataSource

#pragma mark 

@end

_myVC 的生命周期是什么?它会被呈现多次吗? - Jeffery Thomas
myVC 只创建一次,使用一个 xib,其视图输出口在文件所有者中设置。每次我按下一个 UIButton 时,它都会被呈现 - 在上述代码运行的地方。 - DanMoore
你能展示那段代码吗?我怀疑视图控制器中的某些东西在欺骗弹出窗口。 - Jeffery Thomas
我已根据你的要求编辑了我的问题。谢谢 Jeffery。 - DanMoore
你有没有解决这个问题的好运气?我也遇到了同样的问题,不知道该怎么办。 - user1244109
1个回答

0

我在模态展示方面遇到了一些问题。我的错误是在viewDidLoad中以模态方式呈现它。你可以尝试在viewDidAppear中呈现它。这在我的情况下解决了问题。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接