ios - UIView inside UIView with TextField and Button not working -


good afternoon,

i'm trying show uiview when (in case) there isn't result show in tableview filled products. when detect 0 products, show uiview contains label, textfield , button, can't interact textfield , neither button.

it's first time using technique show uiview when went wrong tableview know what's wrong in code , i'm missing because it's weird.

here code (when print "product not found" show uiview):

import uikit import social  class productocamviewcontroller: uiviewcontroller, uitableviewdatasource, uitableviewdelegate {  @iboutlet var productoimageview:uiimageview! @iboutlet var tableview:uitableview!  @iboutlet weak var noencontrado:uiview!  var productoimage:string!  var ean:string!  var producto:producto!  var productos = [producto]()  @iboutlet weak var toolbar: uitoolbar!  @iboutlet weak var cargando: uiactivityindicatorview!  override func viewdidload() {      toolbar.hidden = true      noencontrado.hidden = true      cargando.hidden = false      super.viewdidload()      // set table view background color     self.tableview.backgroundcolor = uicolor(red: 240.0/255.0, green: 240.0/255.0, blue: 240.0/255.0, alpha: 0.2)      // remove separator     self.tableview.tablefooterview = uiview(frame: cgrectzero)      // change separator color     self.tableview.separatorcolor = uicolor(red: 240.0/255.0, green: 240.0/255.0, blue: 240.0/255.0, alpha: 0.8)      self.tableview.rowheight = uitableviewautomaticdimension     self.tableview.estimatedrowheight = 88.0      requestpost()      cargando.hidden = true      tableview.reloaddata() }  override func viewdidappear(animated: bool) {     tableview.reloaddata() }  override func viewwillappear(animated: bool) {     super.viewwillappear(animated)      self.navigationcontroller?.hidesbarsonswipe = false     self.navigationcontroller?.setnavigationbarhidden(false, animated: true) }  override func didreceivememorywarning() {     super.didreceivememorywarning() }  func requestpost () {      let request = nsmutableurlrequest(url: nsurl(string: "http://www.mywebsite.com/product.php")!)     request.httpmethod = "post"     let poststring = "ean="+ean      request.httpbody = poststring.datausingencoding(nsutf8stringencoding)     let task = nsurlsession.sharedsession().datataskwithrequest(request) {         data, response, error in          if error != nil {             print("error=\(error)")             return         }          // json resultado entero         let responsestring = nsstring(data: data!, encoding: nsutf8stringencoding)!          if (responsestring == "product not found")         {             self.noencontrado.hidden = false             self.tableview.reloaddata()             return         }         else         {             self.productos = self.parsejsondata(data!)              self.toolbar.hidden = false              // reload table view             dispatch_async(dispatch_get_main_queue(), {                 self.tableview.reloaddata()             })         }     }     task.resume() }  func parsejsondata(data: nsdata) -> [producto] {     var productos = [producto]()      {         let jsonresult = try nsjsonserialization.jsonobjectwithdata(data, options: nsjsonreadingoptions.mutablecontainers) as? nsdictionary          noencontrado.hidden = true         // parse json data         let jsonproductos = jsonresult?["lista_productos"] as! [anyobject]          jsonproducto in jsonproductos {              let producto = producto()             producto.imagen = jsonproducto["imagen"] as! string             producto.nombre = jsonproducto["nombre"] as! string             producto.descripcion = jsonproducto["descripcion"] as! string             producto.modo_de_empleo = jsonproducto["modo_de_empleo"] as! string             producto.marca = jsonproducto["marca"] as! string             producto.linea = jsonproducto["linea"] as! string             producto.distribuidor = jsonproducto["distribuidor"] as! string             producto.tamano = jsonproducto["tamano"] as! string             producto.precio = jsonproducto["precio"] as! string             producto.codigo_nacional = jsonproducto["codigo_nacional"] as! string              productos.append(producto)         }     }     catch let parseerror {         print(parseerror)     }      return productos }  func numberofsectionsintableview(tableview: uitableview) -> int {     // return number of sections.     return 1 }  func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int {     // return number of rows in section.     return productos.count }  func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell {      title = productos[indexpath.row].nombre      let cell = tableview.dequeuereusablecellwithidentifier("celldetail", forindexpath: indexpath) as! productotableviewcell      cell.selectionstyle = .none      if let url = nsurl(string: productos[indexpath.row].imagen) {         if let data = nsdata(contentsofurl: url) {             self.productoimageview.image = uiimage(data: data)         }     }      cell.nombre.text = productos[indexpath.row].nombre     cell.descripcion.text = productos[indexpath.row].descripcion     cell.modo_de_empleo.text = productos[indexpath.row].modo_de_empleo     cell.marca.text = productos[indexpath.row].marca     cell.linea.text = productos[indexpath.row].linea     cell.distribuidor.text = productos[indexpath.row].distribuidor     cell.tamano.text = productos[indexpath.row].tamano     cell.precio.text = productos[indexpath.row].precio     cell.codigo_nacional.text = productos[indexpath.row].codigo_nacional      cell.layoutifneeded()      return cell } } 

thanks in advance.

at first, please try provide english code :) anyways. think view should appear nonencontrado. there issues need see storyboard.

  1. the view has userinteraction not enabled. property , can activated in storyboard
  2. the view overlayed else. maybe empty tableview.

as suggestion provide fields in tableview , load datasource. dont need fight views. if provide screens storyboard bit more. luck :)


Comments

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

android - How to create dynamically Fragment pager adapter -

1111. appearing after print sequence - php -