ios - Click on profile from feed - swift -


i have feed showing posts users wanted post something. trying display name of user posted in button (that working). when user pressing button should show viewcontroller name of button user pressed (that semi-working).

what happens is, when user pressing name of user post, name showing in other viewcontroller not same name user pressed.

i hope understand :-)

let me walk through code:

first viewcontroller before viewdidload, creating string:

var sendname = "no name recieved" 

further down page code:

    override func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell {              let cell:updatetableviewcell = tableview.dequeuereusablecellwithidentifier("cell", forindexpath: indexpath) as! updatetableviewcell             let update = updates[indexpath.row]          cell.namebutton.settitle(update.addedbyuser, forstate: .normal)         sendname = (cell.namebutton.titlelabel?.text)!  } 

my prepareforsegue:

override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) {          if(segue.identifier == "showprofilefromfeed") {              let yournextviewcontroller = (segue.destinationviewcontroller as! profiletableviewcontroller)             yournextviewcontroller.viasegue = sendname         }     } 

the button title being changed should in feed, there must wrong sendname because doesn't show same name on other viewcontroller buttontitle says..

hope can understand, otherwise please let me know :-)

it seems me update sendname variable problem. cellforrowatindexpath called whenever new cell displayed, or when table redrawn.

i don't know how app works, if can have multiple posts on screen @ same time, means sendname variable correct if pressing button bottom-most post.

if pressed button other post still name of bottom-most post.

what recommend using ibaction triggered when button clicked change sendname variable. can manually initiate segue.


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -