64 20 44 49
self.automaticallyAdjustsScrollViewInsets = false
btn.userInteractionEnabled = false
//獲取時(shí)間戳對(duì)應(yīng)的時(shí)間
//設(shè)置時(shí)間風(fēng)格
let formart = NSDateFormatter.init()
formart.dateStyle = .MediumStyle
formart.timeStyle = .MediumStyle
//y - 年,M - 月,d - 日,H/ h - 時(shí),m - 分,m - 秒,S - 毫秒,E/e - 周
//2016-10-1 -> "yyyy-MM-dd"
//10:11:10 -> "hh:mm:ss"
// formart.dateFormat = "YYYYMMdd"
formart.dateFormat = "yyyy-MM-dd HH:mm:ss"
//將時(shí)間戳轉(zhuǎn)換成時(shí)間
let date = NSDate.init(timeIntervalSince1970: time)
//將時(shí)間轉(zhuǎn)換成指定格式的字符串
let dateStr = formart.stringFromDate(date)
print(dateStr)
static func BmobUserLogin(userName: String,password: String,result:(Bool,String)->Void) {
//1.通過(guò)用戶名去查找數(shù)據(jù)
let query = BmobQuery.init(className: "UserInfo")
//2.添加約束
query.whereKey("userName", equalTo: userName)
//3.開(kāi)始查找
query.findObjectsInBackgroundWithBlock { (allobjects, error) -> Void in
//判斷查詢結(jié)果
if allobjects.count == 0 {
//賬號(hào)錯(cuò)誤
result(false,"賬號(hào)錯(cuò)誤")
}else {
//賬號(hào)正確
//a.取到唯一的賬號(hào)信息
let object = allobjects.first as! BmobObject
//b.取出密碼
let pass = object.objectForKey("passWord")
//c.判斷密碼是否正確
if pass as! String == password {
//登錄成功
result(true,"登錄成功")
}else {
//密碼錯(cuò)誤
result(false,"密碼錯(cuò)誤")
}
}
}//查詢結(jié)果
//登錄按鈕被點(diǎn)擊
@IBAction func loginAction(sender: UIButton) {
//去云數(shù)據(jù)庫(kù)中查詢數(shù)據(jù),
ToolManager.BmobUserLogin(self.userNameField.text!, password: self.passWordField.text!) { (ret, message) -> Void in
if ret == true {
KVNProgress.showSuccessWithStatus(message)
}else {
KVNProgress.showErrorWithStatus(message)
}
}
}
//自定義控件:
//1.聲明所有的子視圖的屬性
//2.在構(gòu)造方法中將子視圖添加到界面上
//3.計(jì)算子視圖的frame
//注冊(cè)Bmob的appKey
Bmob.registerWithAppKey("72e886436014590cb9ad1c8afd379ef9")
return true
//星級(jí)
let scoreStr = (dataModel?.score)! as NSString
self.starView.score = scoreStr.floatValue
NSUserDefaults.standardUserDefaults().setBool(false, forKey: UD_LoginStatus)
NSUserDefaults.standardUserDefaults().boolForKey(UD_LoginStatus)
NSUserDefaults.standardUserDefaults().objectForKey(UD_currentUserName)
//MARK: - 界面相關(guān)
extension BasicViewController:YTMenuViewDelegate {
func cellDidSelected(index: NSIndexPath) {
//隱藏菜單
self.menuView?.hidden = true
//根據(jù)不同的cell被選中挑戰(zhàn)到不同界面
if index.row == 0 {
}else {
//跳轉(zhuǎn)到分類(lèi)界面
let classC = ClassifyViewController()
classC.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(classC, animated: true)
}
}
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
//通知代理,cell被選中了
self.delegate?.cellDidSelected(indexPath)
}
//MARK: - 菜單協(xié)議
protocol YTMenuViewDelegate {
func cellDidSelected(index: NSIndexPath)
}
class YTMenuView: UIView {
//MARK: - 第一步,聲明所有的子視圖
//1.背景
let bgImageView = UIImageView()
//2.tableView
let tableView = UITableView()
//3.數(shù)據(jù)源數(shù)組
var dataArray:[(String,String)] = [(String,String)]()
//4.代理屬性
var delegate: YTMenuViewDelegate? = nil
總結(jié):記不住的代碼10.12
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
相關(guān)閱讀更多精彩內(nèi)容
- 近日,由張介公博士主講、喜馬拉雅電臺(tái)協(xié)助發(fā)行,全國(guó)各地的學(xué)子紛紛號(hào)召支持下,集科學(xué)教育記憶題材于一體的大型史詩(shī)教育...
- 在瀏覽器 DOM 事件里面,有一些事件會(huì)隨著用戶的操作不間斷觸發(fā)。比如:重新調(diào)整瀏覽器窗口大小(resize),瀏...