1:大家想使用混編的話,記住架橋德撬。
2:當(dāng)項(xiàng)目創(chuàng)建swift的時(shí)候,“文件名-swift”里面已經(jīng)包括了Swift文件和初始化等方法昆庇,注意的一點(diǎn)就是當(dāng)OC調(diào)用Swift的時(shí)候。直接引用頭文件“文件名-swift”就可以,不要添加調(diào)用類***swift.h文件敲长,否則文件會(huì)出現(xiàn)引用框架出現(xiàn)錯(cuò)誤。
import UIKit
class KGCFeedBackView: UIView,UITableViewDataSource,UITableViewDelegate {
/*
// Only override draw() if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
override func draw(_ rect: CGRect) {
// Drawing code
}
*/
let main = UIScreen.main.bounds.size
var mTableView:UITableView!
var testView = UIView()
let arry:[String] = ["為什么中斷了學(xué)習(xí)?","難點(diǎn)沒有講透:","課程進(jìn)度較慢,看著著急啊","不符合選課時(shí)的q期望", "太卡了,等網(wǎng)絡(luò)好了再回來 :","不習(xí)慣在手機(jī)上學(xué)習(xí)","隨便進(jìn)來看看"];
//init Myinit
override init(frame:CGRect){
super.init(frame:CGRect(x:0, y:0, width:SCREEN_HEIGHT, height:SCREEN_WIDTH));
self.backgroundColor = UIColor(red:0.36, green:0.34, blue:0.34, alpha:0.70)
setupSubViews()
initTableView()
}
//View init
func setupSubViews() {
testView = UIView(frame:CGRect(x:120, y:20, width:SCREEN_HEIGHT-240, height:SCREEN_WIDTH-40));
testView.backgroundColor = UIColor.white;
testView.layer.cornerRadius = 5;
testView.layer.masksToBounds = true;
testView.clipsToBounds = true
testView.isHidden = false
self.addSubview(testView)
}
//tableView init
func initTableView() {
mTableView = UITableView(frame:CGRect(x:0, y:0, width:testView.width, height:testView.height))
mTableView.backgroundColor = UIColor.white
mTableView.dataSource = self
mTableView.delegate = self
testView.addSubview(mTableView)
mTableView.register(UITableViewCell.self, forCellReuseIdentifier: "cellID")
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return arry.count;
}
//#pramrk -- DataSource
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.row == 0
{
return SCREEN_WIDTH/8.2+13;
}
return SCREEN_WIDTH/8.2;
}
//#pramrk -- Delegate
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let indentifier = String(format: "Cell%d%d",indexPath.section,indexPath.row)
var cell:UITableViewCell! = tableView.dequeueReusableCell(withIdentifier: indentifier)
if cell == nil {
cell = UITableViewCell(style: .default, reuseIdentifier: indentifier)
}
if indexPath.row == 0 {
cell.backgroundColor = UIColor(red:0.45, green:0.79, blue:0.25, alpha:1.00)
}
cell.textLabel?.text = arry[indexPath.row]
cell.textLabel?.font = UIFont.systemFont(ofSize: 18);
cell.textLabel?.textAlignment = NSTextAlignment.center;
cell.selectionStyle = UITableViewCellSelectionStyle.none
return cell;
}
//#pramrk -- didSelectRowAt
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if indexPath.row == 0 {
return;
}
let string:NSString!
string = String(format:"%d",indexPath.row) as NSString;
reqeustGangWeiData(Path:string)
}
//FeedBack
func reqeustGangWeiData(Path:NSString) {
print(Path);
UIApplication.shared.keyWindow?.showLoadingAnimationView()
Common.postQuestionBankRequest(withUrl:"kgc/app/getPosition", withParm:nil, success: { (respesData:Any) in
UIApplication.shared.keyWindow?.hidenLoadingAnimationView()
}) { (error:Any) in
UIApplication.shared.keyWindow?.hidenLoadingAnimationView()
self.makeToast("網(wǎng)絡(luò)異常,請(qǐng)稍后重試~", duration:2.0, position:CSToastPositionCenter)
}
self.removeFromSuperview()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}