this is my first post here. I’ll try to get to the point quickly, as I haven’t been able to find an answer to this problem yet. I’m just starting out.
I’m trying to load a view as a popover, and I’m following some tutorials online, but I’m getting an error when I go to compile. Here’s the offending code:
-(IBAction)contestButton:(id)sender;
{
contestView *screen = [[contestView alloc] init];
UIPopoverController *pop = [[UIPopoverController alloc] initWithContentViewController:contestView];
[pop setDelegate:self];
[pop presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
[pop setPopoverContentSize:CGSizeMake(615, 650)];
[screen release];
}
And the error:
“Expected expression before ‘contestView’ “
I apologize for what seems to me like a very small mistake that I just can’t seem to snake out, but I appreciate your help.
You seem to have a class named
contestView. You have created an instance ofcontestViewand stored it in the variablescreen. Then you try to passcontestView(the class name) as an argument to the selectorinitWithContentViewController:. You cannot pass a bare class name as an argument.Perhaps you meant to say this:
By the way, it is conventional in iOS programming to start a class name with a capital letter. So you should strongly consider renaming the class to
ContestView.Also, the method
-[UIPopoverController initWithContentViewController:]takes an instance ofUIViewControlleras an argument – not an instance ofUIView. If yourcontestViewclass is a subclass ofUIView, you will get a different error once you fix your call to sayscreeninstead ofcontestView.If
contestViewis a subclass ofUIViewController, you should rename it toContestViewController.