Posts

Showing posts from December, 2018

How to Pull Up Refresh in UITableView or UICollectionView

Step 1 :-  Create Object var pullRefresh : UIRefreshControl = UIRefreshControl () Step 2 :- initialise with Controller  pullRefresh . addTarget ( self , action: #selector ( self . pullRefreshView ), for: . valueChanged )   pullRefresh . tintColor = UIColor . clear   self . tblOjbect !. addSubview ( pullRefresh )   self . tblOjbect !. alwaysBounceVertical = true   self . tblOjbect !. bounces = true Step 3:- Create Objective Functions @objc func pullRefreshView() {     pullRefresh . endRefreshing ()     //  Write here what you what on pull Up Refresh }

How to search local array in swift

Delegate :- UITextFiledDelegate, UITableViewDelegate, UITableViewDataSource Let’s create one TableView Object     @IBOutlet weak var tblObj: UITableView! let’s create two array     var arrayMain : NSArray = [ [“ItemName”:”abc” , “id”:”1” , ”price”:12] , [“ItemName”:”def” , “id”:”2” , ”price”:15], [“ItemName”:”ghi” , “id”:”3” , ”price”:52] ]     var arraySearch : NSArray = NSArray() Now let’s create one Bool variable     var isSearch : Bool = false TextFiled Delegate Method func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {         if textField == txtSearch {                          var strSearch = ""             strSearch = String(format: "%@%@", textField.text! , string)                          if string == "" {                 strSearch = (strSearch as NSString).substring(to: (strSearch.count) - 1)             }