iPad UIPopoverController弹出窗口的位置和坐标
2013-08-28 19:12
239 查看
本文转载至:http://blog.csdn.net/chang6520/article/details/7921181
TodoViewController *contentViewController = [[TodoViewController alloc] init];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:contentViewController];
navigationController.contentSizeForViewInPopover = CGSizeMake(100, 100); //内容大小
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:navigationController];
popover.popoverContentSize = CGSizeMake(300, 300); //弹出窗口大小,如果屏幕画不下,会挤小的。这个值默认是320x1100
CGRect popoverRect = CGRectMake(200, 700, 10, 10);
[popover presentPopoverFromRect:popoverRect //popoverRect的中心点是用来画箭头的,如果中心点如果出了屏幕,系统会优化到窗口边缘
inView:self.view //上面的矩形坐标是以这个view为参考的
permittedArrowDirections:UIPopoverArrowDirectionDown //箭头方向
animated:YES];
[contentViewController release];
[navigationController release];
//最佳实践,使用哪个view做参考,就以哪个view的bounds送进去就好了,箭头自动指向这个view的中心。
[popover presentPopoverFromRect:((UIView *)tableview).frame//将popover与tableview视图相关联
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionUp//箭头方向
animated:YES];
popover.popoverContentSize = CGSizeMake(300, 300); //弹出窗口大小。这个没什么好说的,就是大小,当然不能超过屏幕。
[popover presentPopoverFromRect:[b] CGRectMake(x0, y0, x1, y1);[/b]
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionDown //箭头方向
animated:YES];
上面是基本代码,大小没什么可说的。主要是下面这个CGRectMake(x0, y0, x1, y1)函数的四个参数。
先看名字presentPopoverFromRect,from矩形,什么意思,就是说这个popover是出自,来自这个矩形,形象地说就是这个矩形产生出一个用箭头指向的popover.看下面的图,无非这四种情况。这里的四个参数,就是下图中小矩形的参数,大矩形就是
popover。看图就是简单明了,直接了当,不要再说什么矩形中点了,只要确定了小矩形,确定了箭头方向(相对于大矩形),就确定了popover的位置。一般这个小矩形都是button,item什么的。
最后需要注意的是iPad的状态栏20个像素,导航栏44个像素,如果不准确的话,考虑一下二者的因素。一般情况下如果能准确定位图中的三角箭头的顶角的坐标,直接就用它作为前两个参数,而后两个参数为0就可以了,这就把矩形缩小为一个点了,也是正确的。Over!
UIPopoverController * poper...
UIButton * BtnA...
NSArray *array=[NSArray arrayWithObjects:BtnA,BtnB,BtnC,BtnD,BtnE,BtnF,BtnG,BtnH];
poper.passthroughViews=array;
设置passthroughViews为这个数组就可以了~
TodoViewController *contentViewController = [[TodoViewController alloc] init];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:contentViewController];
navigationController.contentSizeForViewInPopover = CGSizeMake(100, 100); //内容大小
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:navigationController];
popover.popoverContentSize = CGSizeMake(300, 300); //弹出窗口大小,如果屏幕画不下,会挤小的。这个值默认是320x1100
CGRect popoverRect = CGRectMake(200, 700, 10, 10);
[popover presentPopoverFromRect:popoverRect //popoverRect的中心点是用来画箭头的,如果中心点如果出了屏幕,系统会优化到窗口边缘
inView:self.view //上面的矩形坐标是以这个view为参考的
permittedArrowDirections:UIPopoverArrowDirectionDown //箭头方向
animated:YES];
[contentViewController release];
[navigationController release];
//最佳实践,使用哪个view做参考,就以哪个view的bounds送进去就好了,箭头自动指向这个view的中心。
[popover presentPopoverFromRect:((UIView *)tableview).frame//将popover与tableview视图相关联
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionUp//箭头方向
animated:YES];
popover.popoverContentSize = CGSizeMake(300, 300); //弹出窗口大小。这个没什么好说的,就是大小,当然不能超过屏幕。
[popover presentPopoverFromRect:[b] CGRectMake(x0, y0, x1, y1);[/b]
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionDown //箭头方向
animated:YES];
上面是基本代码,大小没什么可说的。主要是下面这个CGRectMake(x0, y0, x1, y1)函数的四个参数。
先看名字presentPopoverFromRect,from矩形,什么意思,就是说这个popover是出自,来自这个矩形,形象地说就是这个矩形产生出一个用箭头指向的popover.看下面的图,无非这四种情况。这里的四个参数,就是下图中小矩形的参数,大矩形就是
popover。看图就是简单明了,直接了当,不要再说什么矩形中点了,只要确定了小矩形,确定了箭头方向(相对于大矩形),就确定了popover的位置。一般这个小矩形都是button,item什么的。
最后需要注意的是iPad的状态栏20个像素,导航栏44个像素,如果不准确的话,考虑一下二者的因素。一般情况下如果能准确定位图中的三角箭头的顶角的坐标,直接就用它作为前两个参数,而后两个参数为0就可以了,这就把矩形缩小为一个点了,也是正确的。Over!
多个UIPopoverController的切换问题
情况描述:多个button控制对应的UIPopoverController,当一个UIpopverController_A打开的时候,点击button_B去打开另外一个UIPopverContrller_B,每次都需要点击两下才能打开,(我的理解)第一次只是关闭UIpopverController_A,第二次才是打开UIPopverContrller_B。
解决方法:UIPopoverController * poper...
UIButton * BtnA...
NSArray *array=[NSArray arrayWithObjects:BtnA,BtnB,BtnC,BtnD,BtnE,BtnF,BtnG,BtnH];
poper.passthroughViews=array;
设置passthroughViews为这个数组就可以了~
UIPopoverController如何改变边框颜色?
http://www.cocoachina.com/bbs/simple/?t25154.html相关文章推荐
- iPad UIPopoverController弹出窗口的位置和坐标
- iPad UIPopoverController弹出窗口的位置和坐标
- iPad UIPopoverController弹出窗口的位置和坐标——再探
- iPad UIPopoverController弹出窗口的位置和坐标
- iPad UIPopoverController弹出窗口的位置和坐标
- 终于弄明白iPad UIPopoverController弹出窗口的位置和坐标了
- iPad UIPopoverController弹出窗口的位置和坐标——终结篇
- iPad UIPopoverController弹出窗口的位置和坐标初探
- 终于弄明白iPad UIPopoverController弹出窗口的位置和坐标了
- iOS4 - UIPopoverController弹出窗口的位置和坐标(转载)-待整理
- 自定义dialog窗口,根据坐标可随意设置dialog显示位置,实现了窗口弹出动画
- 用户控件 + ScriptManager 实现点击后弹出窗口且窗口坐标追随点击位置效果
- 用户控件 + ScriptManager 实现点击后弹出窗口且窗口坐标追随点击位置效果
- IOS4 -- UIPopoverController弹出窗口的位置和坐标
- IOS4 -- UIPopoverController弹出窗口的位置和坐标
- 显示弹出窗口popup到指定位置
- js获取窗口相对于屏幕左边和上边的位置坐标
- ipad弹出窗口
- 关于iPhone/iPad的iOS系统自动弹出认证窗口问题
- javascript:window.open弹出窗口的位置问题