Search This Blog

Thứ Tư, 12 tháng 9, 2018

Trượt đến cuối khung chat


@objc internal func scrollToBottom(_ animated: Bool = false) {
        let boundsHeight = collectionView?.bounds.size.height ?? 0
        let sizeHeight = collectionView?.contentSize.height ?? 0
        let offset = CGPoint(x: 0, y: max(sizeHeight - boundsHeight, 0))
        collectionView?.setContentOffset(offset, animated: animated)
        scrollToBottomButtonIsVisible = false
    }

Thứ Sáu, 24 tháng 8, 2018

Làm mới lại khi chọn 1 dòng trong table view in ios


func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        

        tableView.deselectRow(at: indexPath, animated: true)
        tableView.reloadData()
    }

Show thông báo ra màn hình in ios


private func showMessage() {
        
        let alert = UIAlertController(title: nil, message: viewModel.message, preferredStyle: .alert)
        alert.addAction(UIAlertAction(title: localized("ok"), style: .default, handler: nil))
        present(alert, animated: true)
    }

Thứ Năm, 16 tháng 8, 2018

Lưu string với Localizable.strings in ios

1. Tạo file lưu dữ liệu :



2.Truy xuất nó :


createServerButtton.setTitle(
                localized("auth.login.button_login_title"),
                for: .normal
)

didSet lại 1 button


 @IBOutlet weak var createServerButtton: UIButton! {
        didSet {
            createServerButtton.setTitle(
                localized("auth.login.button_login_title"),
                for: .normal
            )
        }
    }

Thứ Ba, 16 tháng 1, 2018

Cập nhật dữ liệu Realm in IOS

let workouts = realm.objects(WorkoutsCount.self).filter("date = %@", removeTodaysItem)

let realm = try! Realm()
if let workout = workouts.first {
    try! realm.write {
        workout.date = today
        workout.count = plusOne
    }
}