phonegap/phonegap-plugins — Issue #378: Permit ActionSheet to use showFromRect:CGRectMake() for iPad popovers
Author: kerrishotts
Created: 2012-03-08 07:24:11+00:00
State: open

This would permit actionsheet popovers to correctly indicate with an arrow where they originate from. (A must for tab bars, toolbars, etc.)

Something like the following would work as a start: (in ActionSheet.m)

-(void)create:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
{
...
NSInteger rectx = [[options objectForKey:@"rectx"] intValue] ?: -1;
NSInteger recty = [[options objectForKey:@"recty"] intValue] ?: -1;
NSInteger rectw = [[options objectForKey:@"rectw"] intValue] ?: 1;
NSInteger recth = [[options objectForKey:@"recth"] intValue] ?: 1;
...

[actionSheet showFromRect:CGRectMake( rectx, recty, rectw, recth ) inView:self.webView.superview animated:YES];
}

And in ActionSheet.js:

ActionSheet.prototype.create = function(title, items, fn, options, rx, ry, rw, rh) {
...
var config = { ...
rectx : ((rx) ? rx : -1),
recty : ((ry) ? ry : -1),
rectw : ((rw) ? rw : 1),
recth : ((rh) ? rh : 1)
}

I'm sure the above can be greatly improved upon; regardless the feature itself would be fantastic to have built-in. TBH, I'm surprised ActionSheet didn't already have the functionality, but I _have_ seen other apps use a center popover instead of one with an arrow (AlienBlue to be specific), so Apple must not reject on that, but it _feels_ like something they could fuss over.