It is my first app that I am trying to build in IOS and I have some problems. Although I have read similar threads here I was not able to find the answer.I want to show popoverview controller on my button click.but unable to do. i am getting error mention in question title above below 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.
You need to tell the compiler that sender
is, in fact, a 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]
rather than:
sender.frame
NOTE: the name Getcompany
is not conventional for an Objective-C method; I don't know what it does, but if it's an action method, then something like this is probably better:
- (IBAction)companyButtonPressed:(id)sender
(note lowercase starting letter and camel-case formatting).