显示导航控制器在上面

我已经在我的应用程序中设置了一个子视图“popup”,我想显示一个navController,如果用户点击子视图popupbutton。 到目前为止,我已经设置了button,但如果我点击button导航控制器出现在我的popup窗口! 我寻找了一些解决scheme,但我没有find任何。 整个控制器实际上显示在一个文件夹,你可以在这里find: https : //github.com/jwilling/JWFolders所以viewDidLoad属于文件夹和rootview。 我试图把它作为popup窗口的子视图,但不起作用。 有谁知道如何治疗? 我已经设置了popup式的程序和navigationController。 提前致谢。

我的代码:

navController设置:

- (IBAction)dothis:(id)sender { MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self]; // Set browser options. browser.wantsFullScreenLayout = YES; browser.displayActionButton = YES; UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:browser]; [self presentModalViewController:navController animated:YES]; NSMutableArray *photos = [[NSMutableArray alloc] init]; MWPhoto *photo; photo = [MWPhoto photoWithFilePath:[[NSBundle mainBundle] pathForResource:@"star" ofType:@"png"]]; photo.caption = @"The star is soo beateful..."; [photos addObject:photo]; self.photos = photos; } - (MWPhoto *)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index { if (index < _photos.count) return [_photos objectAtIndex:index]; return nil; } - (NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser { return _photos.count; } 

popup代码:

  -(IBAction)mehr:(id)sender { //the popup size and content UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 280, 440)]; CGRect welcomeLabelRect = contentView.bounds; welcomeLabelRect.origin.y = 20; welcomeLabelRect.size.height = 40; UILabel *welcomeLabel = [[UILabel alloc] initWithFrame:welcomeLabelRect]; //an simple activityindicator activityindi = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite]; activityindi.frame = CGRectMake(120, 200, 40, 40); [activityindi startAnimating]; [contentView addSubview:activityindi]; //The Imageview CGRect infoimagerect = CGRectMake(5, 70, 270, 200); UIImageView *infoimage = [[UIImageView alloc] initWithFrame:infoimagerect]; //and the Button cubut = [UIButton buttonWithType:UIButtonTypeCustom]; [cubut addTarget:self action:@selector(dothis:) forControlEvents:UIControlEventTouchUpInside]; [cubut setTitle:nil forState:UIControlStateNormal]; cubut.frame = CGRectMake(5, 70, 270, 200); //retrieving data from parse.com PFQuery *query = [PFQuery queryWithClassName:@"My-Application"]; [query getObjectInBackgroundWithId:@"My-ID" block:^(PFObject *textdu, NSError *error) { if (!error) { //hide the Button if there is no image cubut.hidden=YES; //the headline of popup UIFont *welcomeLabelFont = [UIFont fontWithName:@"copperplate" size:20]; welcomeLabel.text = [textdu objectForKey:@"header"]; welcomeLabel.font = welcomeLabelFont; welcomeLabel.textColor = [UIColor whiteColor]; welcomeLabel.textAlignment = NSTextAlignmentCenter; welcomeLabel.backgroundColor = [UIColor clearColor]; welcomeLabel.shadowColor = [UIColor blackColor]; welcomeLabel.shadowOffset = CGSizeMake(0, 1); welcomeLabel.lineBreakMode = UILineBreakModeWordWrap; welcomeLabel.numberOfLines = 2; [contentView addSubview:welcomeLabel]; //the image from parse if (!error) { PFFile *imageFile = [textdu objectForKey:@"image"]; [imageFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error) { if (!error) { UIImage *image = [UIImage imageWithData:data]; infoimage.image = image; infoimage.contentMode = UIViewContentModeScaleAspectFit; //show the button when the image appears cubut.hidden = NO; [contentView addSubview:infoimage]; //stop the activityindicator [activityindi stopAnimating]; } }]; } } else { //show some text welcomeLabel.text = @"No connection!"; [welcomeLabel sizeToFit]; //hide the button cubut.hidden = YES; [contentView addSubview:infoLabel]; //stop the activityindicator [activityindi stopAnimating]; } }]; //add the content to the KNGModal view [[KGModal sharedInstance] showWithContentView:contentView andAnimated:YES]; } 

我的viewDidLoad

 - (void)viewDidLoad { but.hidden = YES; PFQuery *query = [PFQuery queryWithClassName:@"myapp"]; [query getObjectInBackgroundWithId:@"Rgq5vankdf" block:^(PFObject *textu, NSError *error) { if (!error) { but.hidden = NO; but.color = [UIColor colorWithRed:0.90f green:0.90f blue:0.90f alpha:1.00f]; } else { //if failure but.hidden = YES; mol.text = @"No Connection"; } }]; [super viewDidLoad]; } 

图片:

打开文件夹的button: 在这里输入图像说明

该文件夹本身: 在这里输入图像说明

popup窗口: 在这里输入图像说明

提前致谢。

从目前为止的讨论和debugging代码中,您想要使用导航控制器popup照片浏览器。

所以这里是实现这个function的示例代码 ,看看它。

我已经使用了相同的KGModal示例代码,并根据要求进行了扩展。 我已经使用Xib有导航栏的视图。

要从应用程序的任何位置closurespopup窗口,您可以使用下面的行,因为它是共享实例。

 [[KGModal sharedInstance] hideAnimated:YES]; 

更新:

在folderView中显示照片浏览器的原因是,您正试图在folderView中显示photoBrowser,所以它显示在非常小的高度的folderView中,无法看到任何照片。

所以我的build议是,当用户点击popup来查看photoBrowser,你只需删除popup窗口,并从viewController类呈现的photoBrowser,除了这个类以外,一切都通过视图处理。

我已经按照上面的方法进行了修改并且正常工作,对于您提供的代码,请在此下载代码并查看它。

让我知道它是否满足您的需求。

谢谢

我注意到这行代码:

 [[KGModal sharedInstance] showWithContentView: contentView andAnimated: YES]; 

我只能认为,因为它是一个单身人士,它添加contentView在UIApplication的关键窗口。 如果是这样,那么一个模式视图控制器将永远在popup窗口下方。 你可以通过在KGModal类中添加一个新的方法来解决这个问题

 - (void) showWithContentView: (UIView*) contentView inViewController: (UIViewController*) controller andAnimated: (BOOL) animated; 

该方法应该在指定控制器的视图中显示popup窗口; 您应该使用该方法。

编辑

经过一些挖掘,我发现KGModal在另一个窗口上显示popup窗口。 最快的解决办法是closurespopup窗口,然后显示导航控制器。