UIPopoverController在iOS 8 / Xcode 6中没有消失

时间:2014-09-30 14:42:26

标签: ios objective-c ios8 uipopovercontroller

我的应用程序在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中运行我的应用程序时,没有崩溃,但是当我尝试通过点击外部退出popover时,会出现一条错误消息:

attempt to dismiss modal view controller whose view does not currently appear.

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

我无法逃脱iOS 8中的popover !!

有什么想法吗?

更新w / _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

1 个答案:

答案 0 :(得分:0)

我遇到了模态演示的一些问题。我正在做的错误是在viewDidLoad中以模态方式呈现它。您可以尝试在viewDidAppear中显示它。这解决了我的问题。