1.sourceRect:指定箭头所指区域的矩形框范围,以sourceview的左上角为坐标原点
2.permittedArrowDirections:箭头方向
3.sourceView:sourceRect以这个view的左上角为原点
4.barButtonItem:若有navigationController,并且从right/leftBarButtonItem点击后出现popover,则可以把right/leftBarButtonItem看做上面说的sourceView.默认箭头指向up,亲测下来up是最合适的方向,所以在这种情况下可以不设置箭头方向。
-(void)longress:(UILongPressGestureRecognizer *)ges
{
if (ges.state==UIGestureRecognizerStateBegan) {
NSLog(@"长安");
CGPoint point=[ges locationInView:self.tableView];
NSIndexPath *index=[self.tableView indexPathForRowAtPoint:point];
ChatTableViewCell *cell=[self.tableView cellForRowAtIndexPath:index];
MenueChatViewController *meunes=[[UIStoryboard storyboardWithName:@"Chat" bundle:nil]instantiateViewControllerWithIdentifier:@"menuechat"];
meunes.modalPresentationStyle = UIModalPresentationPopover;
meunes.popoverPresentationController.delegate=self;
meunes.popoverPresentationController.sourceView=cell;
meunes.popoverPresentationController.backgroundColor=[UIColor blackColor];
meunes.popoverPresentationController.sourceRect=cell.bounds;
meunes.popoverPresentationController.permittedArrowDirections=UIPopoverArrowDirectionDown;
CGSize szie=CGSizeMake(cell.frame.size.width , 44);
meunes.preferredContentSize=szie;
[self presentViewController:meunes animated:YES completion:nil];
}
}
- (void)prepareForPopoverPresentation:(UIPopoverPresentationController *)popoverPresentationController
{
NSLog(@"123");
}
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller
{
return UIModalPresentationNone;
}