Friday, 15 January 2010

ios - tableview does not display data unless user touches -


After

I am trying to display some data on my tableview, but if I do not touch tableview, it will display Does not information It only displays data when I touch it.

I did some research but I did not find anything similar to my problem. Below is my code. How can I fix it

  Import UIKit class ViewController: UIViewController {@IButlet on myTableView: UITableView! Var MyData: NSMutableArray = NSMutableArray () function getManufacturer2 () {var url: String = "http://00.00.000.000/myWebService" var request: NSMutableURLRequest = NSMutableURLRequest () request.URL = NSURL (string URL) request.HTTPMethod = "GET" NSURLConnection.sendAsynchronousRequest (request line: NSOperationQueue (), completionHandler: {(response: NSURLResponse!, data: NSData!, error: NSError) - & gt; are not valid in the VAR error,:? AutoreleasingUnsafeMutablePointer & LT ; NSError & gt; = undoubtedly jsonResult: NSDictionary! = NSJSONSerialization.JSONObjectWithData (data base: NSJSONReadingOptionskMutableContainers, error: error)? If as NSDictionary (jsonResult! = null) {va r userMomentList: NSMutableArray = NSMutableArray () self.myData = jsonResult.objectForKey ( "Cevap") as NSMutableArray self.myTableView.reloadData ()} and {// JSON Could not load, check the error println (not "jsonResult Is equal to ")}}}} viewDidLoad function override () {super.viewDidLoad (//) Loading the view, generally do any additional setup after a nib from it. GetManufacturer2 ()} override function didReceiveMemoryWarning () {super.didReceiveMemoryWarning () // Dispose of any resource that can be manufactured. } Function Table View (Table View: UITableView, numberOfRowsInSection section: Int) - & gt; Int {if (self.myData.count> 0) {myData.count} Return 0; } Fanq TableView (Tableview: UITWview, CellForruAttaxPath IndexPath: NSIndexpath) - & gt; UITableViewCell {Cell: UITableViewCell = UITableViewCell (style: UITableViewCellStyle.Value1, reuseIdentifier: "myTableCell") var data = self.myData.objectAtIndex (indexPath.row) NSDictionary cell.textLabel? .text = data.objectForKey ("item_title") NSString cell.detailTextLabel? .text = NSString as return cell (as "item_value").  

The updates on the user interface should always be done in the main thread, so get your table again to try to load:

  dispatch_async (dispatch_get_main_queue (), {self.myTableView.'re Loddeta ()})  

No comments:

Post a Comment