Property frame not found on object of type _strong id

This is my first app I am trying to build on IOS and I am having some problems. Although I've read similar threads here, I haven't been able to find an answer. I want to show popoverview controller on my click button.but cant. i get the error in the question above, these are my files

.h file

@property (nonatomic,strong) UIPopoverController *popOver;
@property (nonatomic,strong) SecondViewController *popOverView;

      

.m file

- (IBAction)Getcompany:(id)sender {
    SecondViewController *popoverview=[self.storyboard instantiateViewControllerWithIdentifier:@"popover"];
    self.popOver =[[UIPopoverController alloc] initWithContentViewController:popoverview];
    [self.popOver presentPopoverFromRect:sender.frame  inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];// m getting an error in this line
}

      

Thanx in advance.

+3


source to share


1 answer


You need to tell the compiler that sender

is essentially UIButton

:

- (IBAction)Getcompany:(id)sender {
    UIButton *button = (UIButton *)sender;
    SecondViewController *popoverview=[self.storyboard instantiateViewControllerWithIdentifier:@"popover"];
    self.popOver =[[UIPopoverController alloc] initWithContentViewController:popoverview];
    [self.popOver presentPopoverFromRect:button.frame  inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
}

      

-or -

you can use the form:

[sender frame]

      



but not:

sender.frame

      

NOTE: the name is Getcompany

not a common Objective-C method; I don't know what it does, but if it is an action method, then something like this is probably better:

- (IBAction)companyButtonPressed:(id)sender 

      

(note the lowercase start letter and camel case formatting).

+6


source







All Articles