當前位置:
                    首頁 >
                            前端技术
>                            javascript
>内容正文                
                        
                    javascript
iOS-JSPatch写UITableView
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                iOS-JSPatch写UITableView
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.                        
                                前言
最近項目里面加了JSPatch,方便及時更新線上的一些小的Bug,這里通過JSPatch寫一個UITableView,話不多說直接上代碼。
代碼
控制器代碼
#import "ViewController.h"@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>@property (nonatomic,strong) UITableView *myTableView;@end@implementation ViewController- (void)viewDidLoad{[super viewDidLoad];self.title = @"首頁"; }@endJSPatch代碼
defineClass("ViewController", {viewDidLoad:function() {self.super().viewDidLoad();self.setTitle("JSPatch修改的標題");_myTableView = require('UITableView').alloc().initWithFrame_style(self.view().frame(), 0);_myTableView.setDataSource(self);_myTableView.setDelegate(self);self.view().addSubview(_myTableView);},tableView_cellForRowAtIndexPath: function(tableView, indexPath) {var cell = tableView.dequeueReusableCellWithIdentifier("cell")if (!cell) {cell = require('UITableViewCell').alloc().initWithStyle_reuseIdentifier(0, "cell")}cell.textLabel().setText("JSPatch寫的TableViewCell");//var redColor = require('UIColor').lightGrayColor();//cell.setBackgroundColor(redColor);return cell},tableView_didSelectRowAtIndexPath: function(tableView, indexPath) {tableView.deselectRowAtIndexPath_animated(indexPath, 1);var lvc = require('LabelViewController').alloc().init();self.navigationController().pushViewController_animated(lvc, 1);},tableView_numberOfRowsInSection: function(tableView, section){return 10;}}, {});
 
效果圖
 希望對你有所幫助!
 
總結
以上是生活随笔為你收集整理的iOS-JSPatch写UITableView的全部內容,希望文章能夠幫你解決所遇到的問題。
                            
                        - 上一篇: arcgis教学视频
 - 下一篇: AUTOSAR视频教学