I cant find createPaintView() function in .m files of ti.paint module. where is it ?

You must Login before you can answer or comment on any questions.

Hello people, I had gone through all .m files of ti.paint module but didn't find createPaintView() function in these (you can see here). where to define such methods in our own module ?

when i tried with mine, the error I got was this

[ERROR] Script Error = -[UIView boundBridge:withKrollObject:]: unrecognized selector sent to instance 0xa026280 at moduletest.js (line 10)

the code in .m (other than assets.m)file is(in #pragma Public APIs region)#

#pragma Public APIs
-(id)createView:(id)args
{
    UIView *view=[[UIView alloc]initWithFrame:CGRectMake(0,0,320,460)];
    [view setBackgroundColor:[UIColor redColor]];
    return view;
}
 
-(id)example:(id)args
{
    // example method
    return @"hello world";
}
code in moduletest.js is #
var window = Ti.UI.currentWindow;
var label = Ti.UI.createLabel();
window.add(label);
 
// TODO: write your module tests here
var moduletest = require('ti.moduletest');
Ti.API.info("module is => " + moduletest);
 
var view = moduletest.createView();
window.add(view);
Thank You in advance.

— asked 2 years ago by nitin soni
3 Comments
  • The error is here

    var view = moduletest.createView();

    — commented 2 years ago by nitin soni

  • Question is not closed I still have problem.

    Now i created a class subclass of NSView named it TiPaintView (got .h .m files) and coppied TiPaintView.h and TiPaintView.m files into these and used this new module after process. I got new error

    Script Error = invalid method (createPaintView) passed to TiNewmodModule at app.js

    — commented 2 years ago by nitin soni

  • Ok sorry, for the question I think I have more steps yet to read in module development guide.

    — commented 2 years ago by nitin soni

1 Answer

Accepted Answer

"create" methods are implemented automatically by titanium when building modules. What you are looking for is a class probably called (TiPaint)PaintView, where the name in parenthesis is the module name, as explained here

— answered 2 years ago by Javier Rayon
answer permalink
1 Comment
  • and note that you shouldn't use NSView, since this is for Mac OS, not for iOS! The iOS equivalent is UIView.

    — commented 2 years ago by Javier Rayon

Your Answer

Think you can help? Login to answer this question!