ios - Container views with segmented control in swift -


i have segmented control 3 segments. "cattle", "sheep" , "goats". in sheep , goats there segmented control "rfid" , "mobs"

i have used 3 container views on parent viewcontroller, cattleview, sheepgoatmob view , sheepgoatrfid view have uitableviewcontrollers cattletableviewcontroller, sheepgoatmobtableviewcontroller , sheepgoatrfidtableviewcontroller. parent view contains if statement hide/show each view, works okay..

the problem having each child view needs able send info on pages soap web service uibarbuttonitem on parent view. first thought have "send" button in each child view because 3 views loaded memory when app starts, button doesn't know view function call.

edit : how can accomplish setting button in each of 3 views uibarbuttonitem of parent viewcontroller , allowing correct function childviewcontrollers called?

option 2: how access 3 childviewcontroller's function through uibarbuttonitem on parent viewcontroller?

i found solution have 3 views loaded memory , able change function calling using @julian's response: objective-c: how invoke method in container view controller

//determine view showing , point correct child class func sendtransactionbutton(sender: uibarbuttonitem) {    log.debug("send transaction button called p2p")      childviewcontroller in self.childviewcontrollers {          if childviewcontroller.iskindofclass(cattletableviewcontroller) && containertableviewcattle.hidden == false {              var cattlevc = childviewcontroller as! cattletableviewcontroller             cattlevc.transactions()          } else if childviewcontroller.iskindofclass(sheepgoatrfidtableviewcontroller) && containersheepgoatsrfid.hidden == false {              var sheepgoatrfidvc = childviewcontroller as! sheepgoatrfidtableviewcontroller             sheepgoatrfidvc.transactions()          } else if childviewcontroller.iskindofclass(sheepgoattableviewcontroller) && containertableviewsheepgoats.hidden == false {              var sheepgoatsmob = childviewcontroller as! sheepgoattableviewcontroller             sheepgoatsmob.transactions()         }     } } 

you need ensure other views hidden or warning xcode.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -