![](/img/trans.png)
[英]UIPopovercontroller not dismissing from UILongPressGestureRecognizer
[英]UIPopoverController not dismissing in iOS 8 / Xcode 6
我的應用程序在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中的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
我遇到了模態演示的一些問題。 我正在做的錯誤是在viewDidLoad中以模態方式呈現它。 您可以嘗試在viewDidAppear中顯示它。 這解決了我的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.