bang590 / JSPatch

JSPatch bridge Objective-C and Javascript using the Objective-C runtime. You can call any Objective-C class and method in JavaScript by just including a small engine. JSPatch is generally used to hotfix iOS App.
MIT License
11.37k stars 2.24k forks source link

slf[methodName].bind is not a function. (In 'slf[methodName].bind(slf)', 'slf[methodName].bind' is undefined), #730

Open winterrain5 opened 7 years ago

winterrain5 commented 7 years ago

slf[methodName].bind is not a function. (In 'slf[methodName].bind(slf)', 'slf[methodName].bind' is undefined),

原以为是在调用block时没有将self替换为slf,但是检查了一遍是没问题的 看了下调用栈: stack: __c@JSPatch.js:71:36 creatTableView@main.js:29:116 JSPatch.js:167:27 [native code] initData@main.js:14:39 JSPatch.js:167:27 [native code] viewDidLoad@main.js:7:33 JSPatch.js:151:41'

是崩溃在创建tableView的代码中:

creatTableView: function() { var secondMenu = HSSecondBBMenu.alloc().initWithOrigin_andHeight({x: 0,y: 0}, 44); secondMenu.setTextColor(UIColor.blackColor()); secondMenu.selectDeafultIndexPath(); secondMenu.setDelegate(self); secondMenu.setDataSource(self); self.view().addSubview(secondMenu); var mainScreen = UIScreen.mainScreen().bounds(); self.setTableView(UITableView.alloc().initWithFrame_style({x: 0, y: 108, width: mainScreen.width(), height: mainScreen.height() - 108 - 64}, 0)); self.tableView().setBackgroundColor(UIColor.colorWithRed_green_blue_alpha(248 / 255, 248 / 255, 248 / 255, 0)); self.tableView().setDelegate(self); self.tableView().setDataSource(self); self.tableView().setTableFooterView(UIView.alloc().initWithFrame(CGRectZero)); self.view().addSubview(self.tableView()); }

但是不知道问题出在哪儿,烦请指教,谢谢

bang590 commented 7 years ago

看不出来,把调用栈里的 viewDidLoad initData 都发来看看,以及指明是哪一行有问题

winterrain5 commented 7 years ago

viewDidLoad: function() { self.super().viewDidLoad(); self.initData(); },

initData: function() { NSNotificationCenter.defaultCenter().addObserver_selector_name_object(self, "cityScreen2Action:", "cityScreen2", null); self.setEdgesForExtendedLayout(0); self.view().setBackgroundColor(UIColor.colorWithRed_green_blue_alpha(248 / 255, 248 / 255, 248 / 255, 0)); self.creatNavigationBar(); self.creatTableView(); // 创建tableView self.setupRefreshView(); self.loadAllTeamData(); self.setCityId("0"); self.setProvinceId("0"); self.setCountyId("0"); },

bang590 commented 7 years ago

你断点JSPatch.js看看 slfmethodNameslf[methodName]分别是什么吧

peter2022Begin commented 3 years ago

问下你这个问题最终是怎么解决的