モジュールコントローラーを開くときにビューを渡す必要があるネイティブモジュールを開発しました。モジュールは基本的に PDF リーダーであり、Titanium コードから渡す必要があるカスタム共有ボタンを配置する必要があります。このボタン ビューは表示され、Classic Titanium アプリで完全に正常に動作し、プログラムでボタンを作成したときにも正常に動作しました。唯一の問題は現在、合金を使用していることです。ボタン用に別のコントロールを作成しましたが、動作しなくなりました。
以下に、デモ コードのスニペットを貼り付けました。
プログラム制御を使用したときに正常に動作していた私のコードは次のとおりです。
App.js:
var shareBase = Ti.UI.createView({
width: 40,
height: 40,
top: 0,
left: 0,
backgroundColor: 'green'
});
var shareview = Ti.UI.createView({
backgroundImage: 'shareview.png',
width: 40,
height: 40,
});
shareBase.add(shareView);
...
...
...
// Below is the code how I am passing the view for the module
var PDF_READER = require('com.investis.docreader');
var document = PDF_READER.createPDFDocument(reportFile.nativePath.trim());
...
document.setCustomView(shareBase); // Share view is being passed
document.setTitle(report.title);
document.display();
Titanium コードから渡されたビューを受け入れるモジュール内のコントローラー:
controller.m
- (void)setCustomView: (id)args {
TiUIViewProxy *_argVw = args;
if (!args) {
NSLog(@"View Proxy nil", nil);
}
[_pdfViewController setCustomView: _argVw.view ]; // _argVw.view gets UIView from ViewProxy
NSLog(@"View assigned here", nil);
NSLog([_argVw description], nil);
NSLog([_argVw.view description], nil);
}
pdfViewController.m - The controller from where original PDF Reader is called, so I need to pass the view to this controller which loads the view into Toolbar
...
_customButton = [[UIBarButtonItem alloc] initWithCustomView: _customView]; // _customView is the view which is passed from controller.m
...
// Now display button items into toolbar
toolbarItems = [NSArray arrayWithObjects:... _customButton, fixedSpace, ..., nil];
上記のコードは正常に機能していました。しかし、コードを Alloy コントローラーとして実装すると、コントローラーからのカスタム ビューのロードが停止します。
App.js
var pdfshare = Alloy.createController("SocialShare", {});
...
document.setCustomView(pdfshare.getView()); // Passing custom view from the controller, other code in the file remain same
...
作成方法のコードSocialShare
は次のとおりです。
SocialShare.xml
<Alloy>
<View id="container" class="container">
<View id="shareIt" onSingletap="shareIt" platform="ios"/>
<View id="shareIt" onSingletap="shareItAndroid" platform="android" />
</View>
</Alloy>
SocialShare.tss
".container":{
backgroundColor: 'yellow',
borderWidth: 2,
borderColor: 'black',
right: 0,
bottom: 0
},
".container[formFactor=tablet]":{
height: 43,
width: 43
},
".container[formFactor=handheld]":{
height: 40,
width: 40
}
SocialShare.js
var args = arguments[0] || {};
...
// Here nothing extra ordinary UI related tasks are performed. Only event handlers for shareIt
モジュール側の同じコードですが、それでも機能しなくなりました。プログラムで生成されたビューを渡すと、正常に動作します。Alloy ビューを別の方法で扱う必要があるかどうか教えてください。私はGoogleでよく検索し、ドキュメントを読みましたが、適切な解決策を見つけることができません.
詳細: - チタン SDK: 3.2.3.GA
合金: 1.3.0
iPhone シミュレーター: 7.1
これまたはパッチに関する解決策があれば教えてください。