
1.调整ipad上UIActionSheet的arrow方向
ipad上面UIActionSheet可以有箭头,但其方向不能像popover那样调整,上面查资料有如下解决方法:
参考:http://stackoverflow.com/questions/3763324/uiactionsheet-change-arrow-position
重要的就是这两句:
Apple doesn't provIDe any access to internal structure for UIActionSheet's internal implementation of showFromrect,but as for arrow direction,there is actually a very Hack-y way to work around this and sort of being able to change arrow direction to a desired direction.
Trick is to mess around the rect parameter in - (voID)showFromrect:(CGRect)rect inVIEw (UIVIEw *)vIEw animated:(BOol)animated. Apple doesn't document this rect parameter very well,butif your original rect will give you a down arrow direction,Feed in a rect with a large height and negative number origin.y will kind of push the action sheet popover all the way up thus showing a upward arrow direction. This is a extreme Hack but it works consistently across firmware.
2.应用
工作中遇到编辑头像,图片来源:camera,album两种,在Iphone上面没有问题,但在Ipad上由于上面区别就有问题了
先dUIActionSheet,但d出来的总是箭头向下的,我想d个箭头向上,以便切换成Popover时在同一位置
初始代码:
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelbuttonTitle:nil destructivebuttonTitle:@"camera" otherbuttonTitles:nil]; [sheet addbuttonWithTitle:@"album"]; // avaterBtn bounds:(0,80,80) [sheet showFromrect:CGRectMake(0,80) inVIEw:avaterBtn animated:YES]; [sheet release];
改为:
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelbuttonTitle:nil destructivebuttonTitle:@"camera" otherbuttonTitles:nil]; [sheet addbuttonWithTitle:@"album"]; [sheet showFromrect:CGRectMake(0,-200,280) inVIEw:avaterBtn animated:YES]; [sheet release];
从事Ios开发快一年了,以后遇到问题时不能网上搜搜解决就行,一定要深入了解其原理
总结以上是内存溢出为你收集整理的UIActionSheet 箭头方向全部内容,希望文章能够帮你解决UIActionSheet 箭头方向所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)