jspatch 學(xué)習(xí)
require('UIImage');
require('UIColor,UIButton,UITableView,UIScreen,UITableViewCell');
defineClass('JPViewController:UIViewController<UITableViewDataSource>', ['data'],{
viewDidLoad:function() {
self.super().viewDidLoad();
var view = self.view();
view.setBackgroundColor(UIColor.redColor());
self.setAutomaticallyAdjustsScrollViewInsets(0);
self.setEdgesForExtendedLayout(0);
var tableView = UITableView.alloc().initWithFrame_style({x: 0, y: 0, width: 375, height: 667}, 0);
tableView.setDataSource(self);
view.addSubview(tableView);
require('NSURLSession,NSURLRequest,NSURL,NSJSONSerialization');
var session = NSURLSession.sharedSession();
// 2.創(chuàng)建請求
var request = NSURLRequest.requestWithURL(NSURL.URLWithString("http://192.168.50.110:8081/urming_pkuie/system/getServiceHomePage?_=1478482875578"));
// 3.創(chuàng)建會話任務(wù)
session.dataTaskWithRequest_completionHandler(request, block('NSData*,NSURLResponse*,NSError*', function(data, response, error) {
// 1).序列化數(shù)據(jù)
var dic = NSJSONSerialization.JSONObjectWithData_options_error(data, 2, null);
// 2).將數(shù)據(jù)轉(zhuǎn)
console.log(dic);
})).resume();
}
,
tableView_numberOfRowsInSection:function(tableView,section){
return 2;
},
tableView_cellForRowAtIndexPath:function(tableView,indexPath) {
var cell = tableView.dequeueReusableCellWithIdentifier("id");
if (!cell) {
cell = UITableViewCell.alloc().initWithStyle_reuseIdentifier(0, "id");
}
cell.textLabel().setText('smallTwo');
cell.textLabel().setTextColor(UIColor.redColor());
return cell;
}
})
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。