开发者

UIActionSheet Change arrow position?

To show a UIActionSheet on the iPad I did this:

[actionSheetX showFromRect:RectX inView:开发者_如何学CmyView animated:YES];

The arrow of the popover points down, can I change this position to point left, up or right, like when using a normal popover?


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, but if 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. Hope it helps.


CGRect cellRect = cell.bounds;
cellRect.size.width = cell.frame.size.width * 2;
cellRect.origin.x = -(cell.frame.size.width + 10.0);
[_actionSheet showFromRect:cellRect inView:cell animated:YES];

Thanks to - overboming.

iPad - Split view controller: It displays action sheet with left arrow at end of the master view (table view) cell. Arrow inside with 10 pixels in the cell. Try this. It is easy to understand the logic of action sheet display. Thanks - Manraj.


The documentation for the -showFromRect:inView: method states this:

On iPad, this method displays the action sheet in a popover whose arrow points to the specified rectangle of the view

This means that you may be able to get it to display the arrow direction you want by fiddling with the rect. However, there's no reason I can think of why you would want to manually set the arrow direction because UIActionSheet will automatically calculate the best arrow direction.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜