Popover is shown null - ios

I'm trying to show a popover with a title, creating a root view controller and instantiating it with my viewController. But, when I show the popover, the content is not shown. Here is the code:
UIViewController *popContentViewController = [[sb instantiateViewControllerWithIdentifier:#"videosTutoriais"] init];
UINavigationController *controller = [[UINavigationController alloc] initWithRootViewController:popContentViewController];
_popover = [[UIPopoverController alloc] initWithContentViewController:controller];
_popover.delegate = self;
[popContentViewController release];
[controller release];
//dados.myPopoverController = popOverController;
[[self popover] presentPopoverFromRect:ancora.bounds inView:ancora permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
Just to be more specific, the title of popover appears normally, but the content doesn't.

Just double check that popContentViewController is not nil. You have the identifier #"videosTutoriais" which looks like it might be a scanning error.

From your code, you are releasing the controller before you display in on the screen. Try releasing it after or in the dealloc method. If you are unsure about memory management. I suggest you try ARC instead to avoid silly errors and mistakes such as this.

The code looked like this:
sb = [UIStoryboard storyboardWithName:#"MainStoryboard_iPad" bundle:nil];
UINavigationController *controller = [[sb instantiateViewControllerWithIdentifier:#"navTutorial"] init];
_popover = [[UIPopoverController alloc] initWithContentViewController:controller];
[[self popover] presentPopoverFromRect:ancora.bounds inView:ancora permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
[controller release];

Related

Why can't I segue to a view controller in my XIB?

In my code below, I am getting an error saying "Property "navigationController" not found on object of type 'iPhoneFirstPageView *'. This worked before in a different project, but it won't work in this XIB. Any ideas?
-(IBAction)Twitter {
TwitterViewController *twitter = [[TwitterViewController alloc] initWithNibName:nil bundle:nil];
//[self presentViewController:twitter animated:YES completion:NULL];
//[self presentModalViewController:twitter animated:YES];
[self.navigationController pushViewController:TwitterViewController animated:YES];
}
Your first problem is that on this line:
[self.navigationController pushViewController:TwitterViewController animated:YES];
You are trying to push the CLASS TwitterViewControllerrather than your object twitter
Your second problem is that iPhoneFirstPageView is a subclass of UIView and not of UIViewController. The cleanest way for someone new to fix this would be in Xcode to create a new file called iPhoneFirstPageViewController that is a subclass of UIViewController.
The solution setup your initial view controllers as the follow:
iPhoneFirstPageViewController *firstViewController = [[iPhoneFirstPageViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:firstViewController];
////Skip to the method you are trying to write. This will be in iPhoneFirstPageViewController.m
-(IBAction)Twitter
{
TwitterViewController *twitter = [[TwitterViewController alloc] init];
[self.navigationController pushViewController:twitter animated:YES];
}

iOS presentViewController View Controller not Fully Loading

With the following code:
MyModalViewController *mMVC = [[MyModalViewController alloc] init];
UINavigationController *mMNavVC = [[UINavigationController alloc] initWithRootViewController:mMNavVC];
mMNavVC.navigationBar.barStyle = UIBarStyleBlackOpaque;
[[[appdelegate window] rootViewController] presentViewController:mMNavVC animated:YES completion:nil];
[mMVC release];
[mMNavVC release];
//(Yes we are not using ARC yet - kills me)
the view presents but it does not load before fully sliding up to the top. The Nav controller does load properly and you see it slide all the way up. However it's just a frame. In other words, you can see the presenting view controller as the nav controller slides up into place - THEN the mMVC loads.
Thanks for the help!
Your problem is that you are trying to create a UINavigationController while using it as the UINavigationController rootviewcontroller. Fixing this line :
UINavigationController *mMNavVC = [[UINavigationController alloc]
initWithRootViewController:mMNavVC];
to this :
MyModalViewController *mMVC = [[MyModalViewController alloc] init];
UINavigationController *mMNavVC = [[UINavigationController alloc] initWithRootViewController:mMVC];
will load the modal view controller before showing it.
MyModalViewController *mMVC = [[MyModalViewController alloc] init];
UINavigationController *mMNavVC = [[UINavigationController alloc] initWithRootViewController:mMNavVC];
mMNavVC.navigationBar.barStyle = UIBarStyleBlackOpaque;
[[[app window] rootViewController].navigationController pushViewController: mMNavVC animated:YES];
[mMVC release];
[mMNavVC release];
Try adding a line where you access that vc's view, i.e.
MyModalViewController *mMVC = [[MyModalViewController alloc] init];
UINavigationController *mMNavVC = [[UINavigationController alloc] initWithRootViewController:mMNavVC];
mMNavVC.navigationBar.barStyle = UIBarStyleBlackOpaque;
mMVC.view.backgroundColor = [UIColor whiteColor];
[[[appdelegate window] rootViewController] presentViewController:mMNavVC animated:YES completion:nil];
[mMVC release];
[mMNavVC release];
This is kind of a workaround for a problem that your viewController's view doesn't get loaded before navigationController's viewDidAppear method is called. If what I posted doesn't work, the problem is elsewhere.
Just try it and tell if it's ok now. :)
OK. Everybody gets a 1up for their answers because they were all helpful to me.
LucOlivierDB gets the check mark because that was just a stupid thing for me to not have seen.
!!NOTE:!! As it turns out my real problem as this line of code:
self.view.backgroundColor = [UIColor clearColor];
Someone thought it would be clever to have all the views inherit the background by making the view transparent. So when it drew the view it was drawing it transparent. Since the was not considered done drawing until the modal action was done you could see the view beneath it before that.
Thanks guys. You call made me think and learn!

What kind of popover on iPad

The iPad app pdf expert displays popovers which seem to consist only of the header. Which kind of popover is this? I can't find something about it in the Apple docs. But it seems to be a standard UI element. Or is it a custom view?
Its nothing like a custom view. Its just without UINavigationController.
ViewController *viewController = [[ViewController alloc] initWithNibName:#"ViewController" bundle:nil];
UIPopoverController * popover = [[UIPopoverController alloc] initWithContentViewController:viewController];
popover.delegate = self;
popover.popoverContentSize = CGSizeMake(644, 425);
[popover presentPopoverFromRect:button.frame inView:self.view permittedArrowDirections: UIPopoverArrowDirectionLeft | UIPopoverArrowDirectionUp animated:YES];
This will solve you problem. Check it out.!!

how to push views iphone?

i'm new to iphone development and i need some guidance in pushing views. I have the following application scenario "press on button ->switch view (contains a table)->press on table cell ->switch view".
To switch when i press the button i use the following code :
MapView *screen = [[MapView alloc] initWithNibName:nil bundle:nil];
screen.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:screen animated:YES];
[screen release];
Then to push another view i want to use this code (but it does not work - and im asking why?)
Newclass *nextController = [[Newclass alloc] initWithItem:theItem];
[self.navigationController pushViewController:nextController animated:YES];
[nextController release];
You want to push this view from your MapView? Looks like you don't have a UINavigationController which is needed to push view controllers like that.
Update the first part of your code to put the MapView inside UINavigationController, than you can push other views onto it with that second part of code you have.
MapView *screen = [[MapView alloc] initWithNibName:nil bundle:nil];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:screen]; // this puts the MapView onto navigation controller
navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; // you will present the navController instead of screen so change it's modalTransitionStyle
[self presentModalViewController:navController animated:YES]; // present it
[screen release];
[navController release]; // don't forget to release

adding an UINavigationController to a UIControllerView

i was searching this whole afternoon in hope of solution but i didn't manage to find anything helping me solve the problem.
The problem is, i have no intention of using UINavigationController until a button gets taped, and after that i would like to present view controller containing a navigationcontroller, or reverse, modally. in my search i came across this solution:
MyExampleViewController *vc = [[[MyExampleViewController alloc] initWithNibName:#"MyExample" bundle:nil] autorelease];
UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:vc] autorelease];
[self presentModalViewController:navController animated:YES];
which i then used it in my code and found out it is not working, to make sure i started a practice project from viewbased project templet and added this to the first view controller
- (IBAction) buttonGotPreseed{
testino *testController = [[testino alloc] initWithNibName:#"testino" bundle:nil];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:testController];
testController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:testController animated:YES];
[nav release];
[testController release];
}
didn't work also, im not seeing the navigation bar up there
any help would be greatly appreciated
You're pushing the root view controller, not the navigation controller itself. Line 5 should be:
[self presentModalViewController:nav animated:YES];

Resources