2

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.

Studio Symposium
  • 287
  • 2
  • 16

1 Answers1

1

You seem to have a class named contestView. You have created an instance of contestView and stored it in the variable screen. Then you try to pass contestView (the class name) as an argument to the selector initWithContentViewController:. You cannot pass a bare class name as an argument.

Perhaps you meant to say this:

UIPopoverController *pop = [[UIPopoverController alloc]
    initWithContentViewController:screen];

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 of UIViewController as an argument - not an instance of UIView. If your contestView class is a subclass of UIView, you will get a different error once you fix your call to say screen instead of contestView.

If contestView is a subclass of UIViewController, you should rename it to ContestViewController.

rob mayoff
  • 375,296
  • 67
  • 796
  • 848