ios - DataSource appears to be working but tableView is not reloading -
i've got issue tableview isn't updating based on datasource correctly. i'm using tabbed application construction storyboards.
my overall goal here have tableview on sec tab display items removed array stored in struct. items added array first tab.
there 2 viewcontrollers (1 interface scrolling through items , selecting remove them, , 1 handle tableview) , 2 views (1 interface scrolling through items , removing them , 1 tableview). first tab providing interface removing items , sec tab tableview.
the remove , add together array functionality works, not displaying in tableview.
currently, if hard code items in "removed items" array, displayed in tableview. problem add together items array removeitem function in first viewcontroller, tableview not update, hard coded items shown.
this makes me assume have datasource , delegate setup correctly, since tableview getting it's info intended datasource. issue it's not updating user updates array new items.
i've tried using self.tableview.reloaddata() no success. might not calling in right location though.
i'm not sure disconnect is.
here sec view controller controls tableview
class secondviewcontroller: uiviewcontroller, uitableviewdatasource, uitableviewdelegate { allow cellidentifier = "cellidentifier" var removedtopicsfromlist = containerforremovedtopics() @iboutlet var tableview: uitableview! override func viewdidload() { super.viewdidload() self.tableview?.registerclass(uitableviewcell.self, forcellreuseidentifier: self.cellidentifier) } override func didreceivememorywarning() { super.didreceivememorywarning() } // uitableviewdatasource methods func numberofsectionsintableview(tableview: uitableview) -> int { homecoming 1 } func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int { homecoming removedtopicsfromlist.removedtopics.count } func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { var cell = tableview.dequeuereusablecellwithidentifier(self.cellidentifier) uitableviewcell cell.textlabel!.text = self.removedtopicsfromlist.removedtopics[indexpath.row] homecoming cell } here struct removed phrases stored
struct containerforremovedtopics { var removedtopics: [string] = [] }
structure instances passed value. if code like:
var removedtopicsfromlist = secondviewcontroller.removedtopicsfromlist removedtopicsfromlist.removedtopics.append("sometopic") secondviewcontroller.reloaddata() then changing different structure.
maybe got stuck problem guess.
ios xcode swift tableview datasource
No comments:
Post a Comment