當前位置:編程學習大全網 - 網站源碼 - oc與js交互?怎麽向網頁註入數據

oc與js交互?怎麽向網頁註入數據

oc與js交互

怎麽向網頁註入數據

下面的示例代碼將調用上面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;

}

  • 上一篇:Upx使用和免殺解決方案
  • 下一篇:把c盤的東西移到d盤後idea打不開
  • copyright 2024編程學習大全網