iphone - How to detect if a table view cell is tapped in xcode 7 -


how detect if table view cell tapped. guides , tutorial on web follow approach of adding button table cell view - prototype cell. button remains same rows , when tapped, returns index of row or cell.

i want without button. how can invoke

@ibaction 

when cell tapped , perform segue inside function.

how should go it?

i added following code, not print anything

class moreviewcontroller: uiviewcontroller, uitableviewdatasource, uitableviewdelegate {  let appdelegate  = uiapplication.sharedapplication().delegate as! appdelegate  let moreoption = [     ("my profile"),     ("settings"),     ("logout") ]  override func viewdidload() {     super.viewdidload()      // additional setup after loading view.     self.navigationcontroller!.navigationbar.bartintcolor = uicolor(red: (48/255.0), green: (187/255.0), blue: (197/255.0), alpha: 1.0);     self.navigationcontroller!.navigationbar.tintcolor = uicolor .whitecolor();     self.navigationcontroller!.navigationbar.translucent = false;     self.navigationcontroller!.navigationbar.titletextattributes = [nsforegroundcolorattributename : uicolor .whitecolor()] }  override func didreceivememorywarning() {     super.didreceivememorywarning()     // dispose of resources can recreated. }  func logout() {     print("logout tapped"); }   func numberofsectionsintableview(tableview: uitableview) -> int {     return 1 }  func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int {     return moreoption.count }  func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell {     let cell = tableview.dequeuereusablecellwithidentifier("cell", forindexpath: indexpath) uitableviewcell     let (celloption) = moreoption[indexpath.row];     cell.textlabel!.text = celloption;     cell.textlabel!.textcolor =  uicolor(red: (74/255.0), green: (74/255.0), blue: (74/255.0), alpha: 1.0);     return cell; }   func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath) {     let cell = tableview.cellforrowatindexpath(indexpath)     print(cell); } 

}

why aren't using uitableviewdelegate method?

func tableview(_ tableview: uitableview, didselectrowat indexpath: indexpath) 

in method indexpath of cell tapped , here can open new controller if want.


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? -