Hello,
I've been trying to figure this one out, but simply can't.
My code is something like this:
//Code 1 -(UIView*)square { if (square==nil) { square = [[UIView alloc] initWithFrame:[self frame]]; [self addSubview:square]; } return square; }Pretty straight forward (right from the modules example).
However, one thing I'm not being able to figure out is how to add this:
//Code 2 square.backgroundColor = [[TiUtils colorValue:color] _color]wherein I wish to obtain color from arguments passed to the TiUIViewProxy when initializing it in my js code as follows:
win.add(module.createView({ width: Ti.UI.FILL, height: Ti.UI.FILL, color: 'black' }));Now, if I set this up by using the setter methods, it works perfectly fine. However, I would like to write Code 2 within Code 1, due to certain restrictions I cannot talk about. So, anyway to access the value for the key 'color' from within Code 1?
2 Answers
Accepted Answer
Hi Nikhil, i don't get the exact problem. but i think module development at wiki is giving good explanation.
How ever if you want to set the color within the initialization code i.e. is your code 1, then you have to call your initialization function from any of the life cycle method. methods like
-(void)frameSizeChanged:(CGRect)frame bounds:(CGRect)bounds { if(square==nil){ [TiUtils setView:[self square] positionRect:bounds]; } if (square!=nil) { [TiUtils setView:square positionRect:bounds]; } }of TiUiView class or any other TiUIViewProxy class life cycle method and you can set the color in the code 1 also.
IOS Objective-C code
-(void)useDocumentOpener:(id)args { ENSURE_UI_THREAD_1_ARG(args); ENSURE_SINGLE_ARG_OR_NIL(args,NSDictionary); NSString *fileName = [TiUtils stringValue:@"path" properties:args ]; .... }in my javascript file
ciDocOpener.useDocumentOpener({ path : tempFile.nativePath });
Your Answer
Think you can help? Login to answer this question!