Navigation Display

I installed subview "popup" in my application and I want to show navController if the user clicked a button on the subview popup. I have installed the button so far, but if I click the button, the navigation controller will appear under my popup !? I was looking for some solution, but could not find. The entire controller is actually displayed in the folder that you can find here: https://github.com/jwilling/JWFolders Thus, viewDidLoad belongs to the folder and the root view. I tried to make this as a sub-popup, but that won't work either. Does anyone know how to relate to this? I also installed popup programmaticaly and navigationController. Thanks in advance.

My code is:

Configuring 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; } 

Pop-up Code:

  -(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]; } 

My 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]; } 

Images:

Button for opening a folder: enter image description here

The folder itself: enter image description here

Pop-up window: enter image description here

Thanks in advance.

+1
source share
2 answers

From discussing and debugging the code you want the photo browser to appear in a pop-up menu using the navigation controller.

So, here is a sample code that implements this functionality, take a look at it.

I used the same KGModal example KGModal and expanded as required. I used Xib to view with the navigation bar.

To reject the popup from anywhere in the application, you can use the line below, as this is a common instance.

 [[KGModal sharedInstance] hideAnimated:YES]; 

Update:

The reason for displaying the photo browser in the View folder is because you are trying to present the photoBrowser file in the View folder, so it was very small in the View folder and could not see any photo.

So my suggestion is that when a user clicks on a pop-up window to view photoBrowser, you simply remove the pop-up window and present the photoBrowser from the viewController class, just like this class, everything is processed through the views.

I made the changes in accordance with the above and works great with the code you specified, download the code here and see it.

Let me know if it meets your needs.

thanks

+1
source

I noticed this line of code:

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

And I can only think that since it is a singleton, it adds a contentView to the contentView key window. If so, then the modal view controller will always be below the popup. You can solve this problem by adding a new method to the KGModal class

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

the method should show a pop-up window in the specified form of the controller; You must use this method.

Edit

After some additional copying, I found that KGModal displays a popup in another window. The quickest fix is ​​to remove the popup and then display the navigation controller.

0
source

All Articles