ios - How do I prevent table view scrolling behind a view? -


in tableviewcontroller, have translucent overlay view message. overlay displayed on tableviewcontroller correctly can still scroll table view behind overlay view. how can prevent scrolling when overlay on top?

i constructed custom overlay view in tableviewcontroller:

override func viewdidload() {     super.viewdidload()      loaddata(         id,         success: {(doc) -> () in             let frame = cgrect(x: 0, y: 0, width: self.view.bounds.size.width, height: self.view.bounds.size.height)              let overlayview = emptycollectionview(frame : frame)             overlayview.backgroundcolor = uicolor(red: 0, green: 0, blue: 0, alpha: 0.8)             self.view.addsubview(overlayview)              self.tableview.reloaddata()         },         error: {..}) } 

i tried self.tableview.isuserinteractionenabled = false

ok - if in uitableviewcontroller, self.view refers uitableview itself. want add overlayview subview of table view's superview...

try this:

tableview.superview?.addsubview(overlayview) 

you can simplify few things well, , should implement sizing control handle changes such device rotation:

let overlayview = emptycollectionview(frame: tableview.frame)  overlayview.autoresizingmask = [.flexiblewidth, .flexibleheight]  overlayview.backgroundcolor = uicolor(red: 0, green: 0, blue: 0, alpha: 0.8)  tableview.superview?.addsubview(overlayview) 

Comments

Popular posts from this blog

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

android - ConstraintLayout: Realign baseline constraint in case if dependent view visibility was set to GONE -

c# - Populating Gridview inside Listview ItemTemplate On Web User Control from Code Behind -