JSPatch下发笔记4

OC代码:

@implementation NewHomeDetailController
- (void)layoutSubviews{
    
    self.homeDetailView = [[NewHomeDetailView alloc]initWithFrame:self.view.bounds];
    [self.view addSubview:self.homeDetailView];
    [self.homeDetailView.collectBtn addTarget:self action:@selector(collection:) forControlEvents:UIControlEventTouchUpInside];
    [self.homeDetailView.weekView addTarget:self action:@selector(weekRent:) forControlEvents:UIControlEventTouchUpInside];
    [self.homeDetailView.monthView addTarget:self action:@selector(monthRent:) forControlEvents:UIControlEventTouchUpInside];
    [self.homeDetailView.publishBtn addTarget:self action:@selector(publish) forControlEvents:UIControlEventTouchUpInside];
    self.homeDetailView.bannerView.collectionViewDelegate = self;
    [self createBottomView];
    [self initRentNumView];
    self.homeDetailView.scrollView.delegate = self;
    
    _listArray = [NSMutableArray arrayWithArray:@[@"\u21e6   首页", @"\u273f   搜索", @"\u2742   社区"]];
    _cellView = [[MLMOptionSelectView alloc] initOptionView];    
    [self initCalendarData];   
}

- (void)createWebView {
    
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@/%@",kAccountManager.WEB_DOMAIN_URL,API_NEISHA_DETAIL,self.proId]];
    _requestUrl=url.absoluteString;
    [self.homeDetailView.webView loadRequest:[NSURLRequest requestWithURL:url]];
    self.homeDetailView.webView.delegate = self;
    [_homeDetailView.webView.wkWebView.scrollView addObserver:self forKeyPath:@"contentSize" options:NSKeyValueObservingOptionNew context:nil];
}
@end

@implementation NSString (Float)
- (NSString *)formatFloat
{
    NSString *str = [NSString stringWithFormat:@"%.2f",self.floatValue];
    return str;
}
@end

JS代码:

require("NewHomeDetailView, NSMutableArray, MLMOptionSelectView,NSString,NSString+Float, NSURLRequest, NSURL,UIFont");
defineClass("NewHomeDetailController", {
            layoutSubviews: function() {
            self.setHomeDetailView(NewHomeDetailView.alloc().initWithFrame(self.view().bounds()));
            self.view().addSubview(self.homeDetailView());
            var UIControlEventTouchUpInside  = 1 << 6;
            self.homeDetailView().collectBtn().addTarget_action_forControlEvents(self, "collection:", UIControlEventTouchUpInside);
            self.homeDetailView().weekView().addTarget_action_forControlEvents(self, "weekRent:", UIControlEventTouchUpInside);
            self.homeDetailView().monthView().addTarget_action_forControlEvents(self, "monthRent:", UIControlEventTouchUpInside);
            self.homeDetailView().publishBtn().addTarget_action_forControlEvents(self, "publish", UIControlEventTouchUpInside);
            self.homeDetailView().bannerView().setCollectionViewDelegate(self);
            self.createBottomView();
            self.initRentNumView();
            self.homeDetailView().scrollView().setDelegate(self);
            var str1 = "\U0000e75f";
            self.setValue_forKey(["\u21e6   首页", "\u273f   搜索", "\u2742   社区"], "_listArray");
            self.setValue_forKey(MLMOptionSelectView.alloc().initOptionView(), "_cellView")
            self.initCalendarData();
            }
            });
defineClass("NewHomeDetailController", {
            createWebView: function() {
            var url = NSURL.URLWithString(NSString.stringWithFormat("http://www.neisha.cc/app/pro/iosD/%@",self.proId()));
            var _requestUrl = self.valueForKey("_requestUrl");
            _requestUrl = url.absoluteString();
            self.homeDetailView().webView().loadRequest(NSURLRequest.requestWithURL(url));
            self.homeDetailView().webView().setDelegate(self);
            var _homeDetailView = self.valueForKey("_homeDetailView");
            _homeDetailView.webView().wkWebView().scrollView().addObserver_forKeyPath_options_context(self, "contentSize", 0x01, null);
            }
            }, {});
defineClass("NSString", {
            formatFloat: function() {
            var str = NSString.stringWithFormat("%@",self.floatValue().toFixed(2));
            return str;
            }
            });

总结:
1.修改多个类中的代码,用defineClass("");分隔。
2.遇到枚举值用原值代替

你可能感兴趣的:(JSPatch下发笔记4)