Search This Blog

Thứ Năm, 4 tháng 4, 2019

Tạm dừng video trong ios

var htmlPlayer = document.getElementsByTagName('video');

function pausePlayer() {
  for(var i = 0; i < htmlPlayer.length; i++){
    htmlPlayer[i].pause();
  }
}

Thứ Hai, 10 tháng 12, 2018

Xóa cache in ios

URLCache.shared.removeAllCachedResponses()
URLCache.shared.diskCapacity = 0
URLCache.shared.memoryCapacity = 0

if let cookies = HTTPCookieStorage.shared.cookies { 
    for cookie in cookies {
        HTTPCookieStorage.shared.deleteCookie(cookie)
    }
}

func clear(cache: Bool, cookies: Bool) {
    if cache { clearCache() }
    if cookies { clearCookies() }
}

fileprivate func clearCache() {
    URLCache.shared.removeAllCachedResponses()
    URLCache.shared.diskCapacity = 0
    URLCache.shared.memoryCapacity = 0
}

fileprivate func clearCookies() {
    let cookieStorage = HTTPCookieStorage.shared

    guard let cookies = cookieStorage.cookies else { return }

    for cookie in cookies {
        cookieStorage.deleteCookie(cookie)
    }
}

Thứ Hai, 19 tháng 11, 2018

Lấy phiên bản hiện tại trong ios

let appVersion = Bundle.main.infoDictionary!["CFBundleShortVersionString"] as? String
//First get the nsObject by defining as an optional anyObject
let nsObject: AnyObject? = NSBundle.mainBundle().infoDictionary["CFBundleShortVersionString"]

//Then just cast the object as a String, but be careful, you may want to double check for nil
let version = nsObject as String

Lỗi không có âm thanh trên video


try! AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, with: [])

Thứ Ba, 6 tháng 11, 2018

Tao bien mo rong in ios


extension Notification.Name {
    static var kAVPlayerViewControllerDismissingNotification = Notification.Name.init("dismissing")
  
}

Thứ Năm, 25 tháng 10, 2018

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
)