怎麽向網頁註入數據
下面的示例代碼將調用上面NativeOcClass的方法,在js層我們只需要這樣調用:
var
ret
=
jsb.reflection.callStaticMethod("NativeOcClass",
"callNativeUIWithTitle:andContent:",
"cocos2d-js",
"Yes!
you
call
a
Native
UI
from
Reflection");
這裏是這個方法在OC的實現,可以看到是彈出壹個native的對話框。並把title和content設置成妳傳入的參數,並返回壹個boolean類型的返回值。
+(BOOL)callNativeUIWithTitle:(NSString
*)
title
andContent:(NSString
*)content{
UIAlertView
*alertView
=
[[UIAlertView
alloc]
initWithTitle:title
message:content
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK",
nil];
[alertView
show];
return
true;
}