Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
TextFiled (Giriş verileri) Değer Kontrolü | Swift ---- http://www.bulentsiyah.com/textfiled-giris-verileri-deger-kontrolu-swift/
//
// BildirenTableViewController.swift
// Bildir-Basic
//
// Created by Bülent Siyah on 12.05.2018.
// Copyright © 2018 Bülent Siyah. All rights reserved.
//
import UIKit
class BildirenTableViewController: UITableViewController, UITextFieldDelegate {
@IBOutlet weak var adiSoyadi: UITextField!
@IBOutlet weak var gsm: UITextField!
@IBOutlet weak var eposta: UITextField!
let webService: WebService = WebService()
var boxView = UIView()
var window = UIWindow()
let defaults = UserDefaults.standard
override func viewDidLoad() {
super.viewDidLoad()
gsm.delegate = self
//self.title = "Bildiren1"
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Bildir", style: .plain, target: self, action: #selector(bildirTabbed))
}
func textFieldDidBeginEditing(_ textField: UITextField) { //delegate method
}
func textFieldDidEndEditing(_ textField: UITextField) {
}
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
let allow = CharacterSet.decimalDigits
let chrset = CharacterSet(charactersIn: string)
return allow.isSuperset(of: chrset)
}
@objc func bildirTabbed() {
if let temp = adiSoyadi.text{
if temp == ""{
self.mesajGoster("Ad Soyad Giriniz")
return
}
}
var gsmm = ""
if let temp = gsm.text{
gsmm = temp
// if temp == ""{
// self.mesajGoster("GSM giriniz")
// return
// }
}
var epostta = ""
if let temp = eposta.text{
epostta = temp
// if temp == ""{
// self.mesajGoster("Eposta giriniz")
// return
// }
}
if gsmm == "" && epostta == "" {
self.mesajGoster("GSM ve/veya Eposta giriniz")
return
}
do{
if(gsmm.count>1){
let index = self.gsm.text?.index((self.gsm.text?.startIndex)!, offsetBy: 0)
var bcc = self.gsm.text?[index!]// String((self.gsm.text?.prefix(0))!)
if(bcc == "0"){
self.mesajGoster("GSM ilk numara 0 ile başlamadan giriniz. Örn:5554443322")
return
}else if((self.gsm.text?.count)! > 10 ){
self.mesajGoster("GSM ilk numara 0 ile başlamadan giriniz. Örn:5554443322")
return
}
var bb = 1
}
}catch{
}
StaticObject.gonderilcekNotification.NameSurname = adiSoyadi.text
StaticObject.gonderilcekNotification.GsmNumber = gsm.text
StaticObject.gonderilcekNotification.Email = eposta.text
addSavingPhotoView()
self.webService.Notification(token: StaticObject.token, tNotification: StaticObject.gonderilcekNotification){
(result: String) in
if(result == "İşlemler sırasında hata oluştu. Lütfen daha sonra tekrar deneyiniz."){
self.boxView.removeFromSuperview()
self.mesajGoster(result)
} else{
let alert = UIAlertController(title: "Bildirildi", message: result, preferredStyle: .alert)
let okButton = UIAlertAction(title: "Tamam", style: .cancel, handler: {
(UIAlertAction)
in
self.webService.Notification(justOpen:StaticObject.justOpen,token: StaticObject.token){
(result: String) in
self.boxView.removeFromSuperview()
//self.mesajGoster_title( "Bildirildi", result, "Tamam")
// self.mesajGoster_title( "Bildirildi", "Bildiriminiz başarıyla iletildi. Bildirimlerinizi bildirimlerim sayfasından kontrol edebilirsiniz.", "Tamam")
/* var yenibildirim = Notificationn()
yenibildirim.Aciklama = StaticObject.gonderilcekNotification.Description
yenibildirim.UID = StaticObject.gonderilcekNotification.Guid
yenibildirim.KonuUID = StaticObject.gonderilcekNotification.SubjectUID
yenibildirim.BilgilendirAdiSoyadi = StaticObject.gonderilcekNotification.NameSurname
yenibildirim.BilgilendirGSM = StaticObject.gonderilcekNotification.GsmNumber
yenibildirim.BilgilendirEPosta = StaticObject.gonderilcekNotification.Email
yenibildirim.No = ""
yenibildirim.AtananKullaniciUID = ""
yenibildirim.Durum = 0
yenibildirim.DurumAciklama = "Yeni"
yenibildirim.GunSayisi = 0
yenibildirim.Latitude = StaticObject.gonderilcekNotification.Latitude
yenibildirim.Longitude = StaticObject.gonderilcekNotification.Longtitude
yenibildirim.OlusturmaTarihi = ""
StaticObject.NotificationList.append(yenibildirim)*/
self.performSegue(withIdentifier: "toLogineGec", sender: nil)
}
})
alert.addAction(okButton)
self.present(alert, animated: true, completion: nil)
}
}
}
override func viewWillAppear(_ animated: Bool) {
if #available(iOS 11.0, *) {
self.title = "Bildiren"
self.navigationItem.backBarButtonItem?.title = "Geri"
self.tabBarController?.navigationItem.title = "Geri"
self.navigationController?.navigationBar.topItem!.title = "Geri"
//self.tabBarController?.navigationItem.title = "Bildir"
//self.navigationController?.navigationBar.topItem!.title = "Bildir"
self.navigationController?.navigationBar.prefersLargeTitles = true
self.navigationController?.navigationBar.topItem!.largeTitleDisplayMode = .always
self.navigationItem.largeTitleDisplayMode = .always
} else {
}
//adiSoyadi.text = StaticObject.kullanici.Adi! + " "+StaticObject.kullanici.Soyadi!
//gsm.text = StaticObject.kullanici.GSM
//eposta.text = StaticObject.kullanici.EPosta
}
func addSavingPhotoView() {
// You only need to adjust this frame to move it anywhere you want
boxView = UIView(frame: CGRect(x: view.frame.midX - 90, y: view.frame.midY - 95, width: 180, height: 50))
boxView.backgroundColor = UIColor.white
boxView.alpha = 0.8
boxView.layer.cornerRadius = 10
//Here the spinnier is initialized
let activityView = UIActivityIndicatorView(activityIndicatorStyle: UIActivityIndicatorViewStyle.gray)
activityView.frame = CGRect(x: 0, y: 0, width: 50, height: 50)
activityView.startAnimating()
let textLabel = UILabel(frame: CGRect(x: 45, y: 0, width: 200, height: 50))
textLabel.textColor = UIColor.gray
textLabel.text = "Lütfen Bekleyin"
boxView.addSubview(activityView)
boxView.addSubview(textLabel)
view.addSubview(boxView)
}
/*
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath)
// Configure the cell...
return cell
}
*/
/*
// Override to support conditional editing of the table view.
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
// Return false if you do not want the specified item to be editable.
return true
}
*/
/*
// Override to support editing the table view.
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
// Delete the row from the data source
tableView.deleteRows(at: [indexPath], with: .fade)
} else if editingStyle == .insert {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/
/*
// Override to support rearranging the table view.
override func tableView(_ tableView: UITableView, moveRowAt fromIndexPath: IndexPath, to: IndexPath) {
}
*/
/*
// Override to support conditional rearranging of the table view.
override func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool {
// Return false if you do not want the item to be re-orderable.
return true
}
*/
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment