钛模块:将Titanium.UI.Button传递到模块中,以显示UIPopoverController

钛模块:将Titanium.UI.Button传递到模块中,以显示UIPopoverController,titanium,uipopovercontroller,titanium-mobile,titanium-modules,titanium-proxy,Titanium,Uipopovercontroller,Titanium Mobile,Titanium Modules,Titanium Proxy,我正在开发一个适用于iPhone和iPad的模块。在本模块中,我尝试模拟UIActivityViewController,并将显示iPhone和iPad的自定义 问题:弹出框显示在iPad屏幕的左上角。我显示弹出窗口的按钮被创建到Tianium SDK中,我将相同的按钮作为参数传递到模块中,模块将使用相同的按钮在特定位置显示弹出窗口 请检查下面我的代码:[代码比粘贴的代码大得多,但我简化了代码,只粘贴了显示代码工作原理的基本代码。] 钛代码: 钛模块:com.xyz.sharing 模块h 模块

我正在开发一个适用于iPhone和iPad的模块。在本模块中,我尝试模拟UIActivityViewController,并将显示iPhone和iPad的自定义

问题:弹出框显示在iPad屏幕的左上角。我显示弹出窗口的按钮被创建到Tianium SDK中,我将相同的按钮作为参数传递到模块中,模块将使用相同的按钮在特定位置显示弹出窗口

请检查下面我的代码:[代码比粘贴的代码大得多,但我简化了代码,只粘贴了显示代码工作原理的基本代码。]

钛代码:

钛模块:com.xyz.sharing

模块h

模块m

代理

代理

程序运行时的输出


由于这个问题,我的Popover显示在iPad屏幕的左上角。有人愿意帮忙解决这个问题吗?如果我尝试使用TiUIButton或TiUIButtonProxy,结果也是一样的。

你工作太辛苦了

[popover      presentFromRect:self.exportView.bounds
                       inView:self.exportView
     permittedArrowDirections:arrowDirections
                     animated:animated];

Ti.AirPrint模块实际演示了这一点:

我刚刚替换了以下代码

[popover presentPopoverFromRect:rect inView:[[TiApp app] controller].view permittedArrowDirections:arrowDirections animated:animated];


在shareContent函数中,这解决了我的问题。

Hi,Mobihunterz您能告诉我您的Tianium javascript代码中的shareController是什么吗。我正在使用您的示例制作一个从Tianium调用本机ios代码的演示。
@implementation ComXYZSharingModule
// Ignoring built-in methods, I have pasted only Custom methods
- (id) shareViewController {
    ComXYZSharingProxy *proxy = [[ComXYZSharingProxy alloc] init];
    proxy.module = self;
    return proxy;
}
@end
@interface ComXYZSharingProxy : TiProxy

@property (nonatomic, strong) ComXYZSharingModule *module;
@property (nonatomic, strong) NSDictionary *content;
@property (strong, nonatomic) TiViewProxy *exportView;

- (void) shareContent : (id) args;
@end
@implementation ComXYZSharingProxy
    - (void) shareContent : (id) args {
        ENSURE_UI_THREAD(shareContent, args);
        NSArray *val = args;
        NSDictionary *dict = [val objectAtIndex: 0];

        self.content = dict;
        if ([dict objectForKey: @"shareButton"]) {
            self.exportView = [dict objectForKey: @"shareButton"]; // This is the Button which gives me wrong values
            NSLog(@"Button Found", nil);
            NSLog([self.exportView description], nil);

            CustomActivityController *controller = [[CustomActivityController alloc] init];  // We have just created the controller which is just customization of UIActivityViewController and that's the main view which will be displayed in Popover for iPad and in modal control for iPhone

            UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:controller];
            //[self setPopoverController:popover];
            //[popover setDelegate:self];
            [popover setBackgroundColor: [UIColor greenColor]];
            popover.popoverContentSize = CGSizeMake(320, 250);
            CGRect rect = [TiUtils rectValue: [self.exportView rect]];

            NSLog([NSString stringWithFormat: @"Size: x: %f,y: %f, width: %f, height: %f", rect.origin.x, rect.origin.y
       , rect.size.width, rect.size.height], nil);

            [popover presentPopoverFromRect:rect inView:[[TiApp app] controller].view permittedArrowDirections:arrowDirections animated:animated];
        }
    }
@end
Button Found
Size: x: 0.00,y: 0.00, width: 0.00, height: 0.00 [This should be actual size of Button but somehow it's not]
[popover      presentFromRect:self.exportView.bounds
                       inView:self.exportView
     permittedArrowDirections:arrowDirections
                     animated:animated];
[popover presentPopoverFromRect:rect inView:[[TiApp app] controller].view permittedArrowDirections:arrowDirections animated:animated];
[popover presentPopoverFromBarButtonItem:[view barButtonItem] permittedArrowDirections:UIPopoverArrowDirectionAny animated: animated];