HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了iPad中popover窗口弹出大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
由于ipad屏幕较大,不像iphone那样经常整页以导航形式滑动,而是将很多信息以popover的形式弹出供显示或编辑。popover原意为淡烤的酥饼,苹果产品中用于指代这种弹出窗口。
 
如下图所示,单击某一行烟草信息即弹出popover窗口供填写订购数量
 

 
 
代码如下:
- (void)tableView:(UITableView *)tableView didSELEctRowATindexPath:(NSIndexPath *)indexPath {
 OrderNumViewController *orderNumViewController = [[OrderNumViewController alloc] init];
 orderNumViewController.containerViewController = self;
 if (orderNumPopover == nil) {
  orderNumPopover = [[UIPopoverController alloc] initWithContentViewController:orderNumViewController];
 }else {
  orderNumPopover.contentViewController = orderNumViewController;
 }
 OrderOnlineCell *cell = (OrderOnlineCell *)[tableView cellForRowATindexPath:indexPath];
 [self showOrderNumPopover:cell];
 [orderNumViewController release];
}
 
-(void)showOrderNumPopover:(OrderOnlineCell *)cell {
 //弹出窗口大小,如果屏幕画不下,会挤小的。这个值认是320x1100
 orderNumPopover.popoverContentSize = CGSizeMake(400,320);
 //popoverRect的中心点是用来画箭头的,如果中心点如果出了屏幕,系统会优化到窗口边缘
 CGRect popoverRect = CGRectMake(cell.bounds.origin.x + cell.bounds.size.width - 100,
         cell.bounds.origin.y,
         27,32);
 [orderNumPopover presentPopoverFromRect:popoverRect
          inView:cell //上面的矩形坐标是以这个view为参
       permittedArrowDirections:UIPopoverArrowDirectionUp //箭头方向
           animated:YES];
}
 
其中需要注意的是如何确定popover弹出的位置和箭头所指方向。

showOrderNumPopover函数中首先确定弹出窗口大小,然后绘制箭头方框,其坐标以传入的单元格视图为参
在实现过程中,因为没搞清楚,以整个tableView作为参确定坐标,导致popover弹出窗口的位置总是不变,一度怀疑cell从table中取出后就失去了关联属性,后来仔细研究下原来要以点击的cell作为参视图确定坐标。

大佬总结

以上是大佬教程为你收集整理的iPad中popover窗口弹出全部内容,希望文章能够帮你解决iPad中popover窗口弹出所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。