UIActionSheet 箭头方向

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上由于上面区别就有问题了
先弹UIActionSheet,但弹出来的总是箭头向下的,我想弹个箭头向上,以便切换成Popover时在同一位置

初始代码:

UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:@"camera" otherButtonTitles:nil];
    [sheet addButtonWithTitle:@"album"];
    // avaterBtn bounds:(0,0,80,80)
    [sheet showFromRect:CGRectMake(0, 0, 80, 80) inView:avaterBtn animated:YES];
    [sheet release];

UIActionSheet 箭头方向_第1张图片

改为:

UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:@"camera" otherButtonTitles:nil];
    [sheet addButtonWithTitle:@"album"];
    [sheet showFromRect:CGRectMake(0, -200, 80, 280) inView:avaterBtn animated:YES];
    [sheet release];

UIActionSheet 箭头方向_第2张图片

从事Ios开发快一年了,以后遇到问题时不能网上搜搜解决就行,一定要深入了解其原理


你可能感兴趣的:(apple,Access,action,UIView,ipad,structure)