help with table views on a uitabbarcontroller - iphone

im writing a news app, and im just planning it out in my head and need some help, before i start coding.
my app is a tab bar controller that is loading and displaying info from an xml feed. i am going to start the download of the xml within the app delegate in the background, so the app does not get closed down by the os, however this means that when my first table loads it will be blank , so i need a way of reloading the table once it has finished . i have encountered this issue before and couldnt work a way round it
last time i started the download of the info from the viewdidload method in the first view controller and tried a reloaddata , but that didn't seem to work. has anyone got a work around for this problem?

[yourTable reloadData] is the way to go.
Make sure to call it on the main thread, and that your data structure is actually holding the correct data.

Related

Preload data in a user friendly way

My application consists of data downloaded from an XML file. data contains short text and images.
currently I'm downloading up all data and building up the view in a view controller, in the ViewDidLoad method, which causes the application not to show up the root view until all data is downloaded. I want it to show up in a more user friendly way, at least to preload some of the data during the splash screen.
By the way I've done the lazy image loading so images can load while the main view is displayed.
As long as the number of views depend on number of rows in XML, loading XML asynchronously while building up the the view does not suite my need (or maybe I'm wrong).
I understand that describing the solution in an answer is quite a challenge, so maybe you could point to an article or even a book that has a detailed explanation of asynchronous and multithread handling.
I don't see why you can't load it asynchronously o_O
You should show some "Loading" view anyway (preferably with an activity Indicator)
A progress bar would be nice, too.
And when it's done downloading you just reload and relayout your view.
If by "number of views" you mean the number of cells in a table row you can just tell the tableview to reload all data whereas your numberOfRowsInSection function (or whatever you want to use) should return appropriate values depending on whether it's loading or not.
EDIT: you shouldn't do that while the application is still loading because that's extremely user-unfriendly and slows down the loading of the application aswell
I think you should parse all data in didFinishLaunchingWithOptions: method of appDelegate and then use following methods to do parsing.
[self performSelectorInBackground:#selector(downloadData:) withObject:nil];
method downloadData: contain parsing procedure.

Page reloading in iPhone Application

Summary of the issue:
When I am loading some data into my iPhone application from a webservice, it populates the tableview two times with double number of records. I found that Viewdidload method is called two times causing this issue.
Scenario
From the first view I parse the webservice and collect the data into an array object.
This array object is being used by the second view to populate the tableview.
I am wondering what is behind reloading of the page causing the tableview has double number of records. Hope somebody can give me a hint.
You may want to consider calling applicationDidFinishLaunchingWithOptions in your app delegate, as this is only called during launch.
Thanks for the tips. What I found the issue was the way adding the view. i replaced [self.view addSubview:trlist.view] with [self presentModelViewController:trlist animated:NO]; and now it loads only one time.

Refreshing data from api after stretching the viewcontroller

I have noticed that applications like facebook and washington post have certain viewcontrollers where if you stretch the viewcontroller below it says that the data is getting to reload. I sense it a better way of reloading the data rather than everytime its being called at viewWillAppear. I am just curious what is that functionality called, and is there any example for this online?
Thanks
It's usually called Pull to Refresh or Pull Down Refresh.
https://github.com/enormego/EGOTableViewPullRefresh

iPhone: how to load objects *after* the main viewcontroller has appeared

Ok hopefully this is an easy question:
I have a main viewcontroller that is loaded by the app delegate at application startup.
This viewcontroller has some code in 'viewDidLoad' to create some non view type based objects (some sound/data objects). Aside from that it also loads a UIView.
The sound/data objects take a while to create, but the app is quite functional without them for a start - so I want to load these objects after the UIView has loaded, but can't seem to figure out how.
I have tried moving the appropriate code to viewDidAppear, but this is still called before the UIView actually appears on screen. Is there a function that is called after the viewcontroller actually starts displaying UIViews, or any other way to achieve what I want?
Any help would be much appreciated - thanks!
In case anyone else has a similar problem, I found a way to solve it: use NSThread to load things in the background without pausing everything else.
There's a good simple example here: http://www.iphoneexamples.com/.

Help getting dataSource working on OpenFlow

I need help getting dataSource in OpenFlow. I
I want to provide CoverFlow functionality whenever the phone is turned horizontally. I'm using Alex Fajkowski's awesome code OpenFlow ( http://fajkowski.com/blog/2009/08/02/openflow-a-coverflow-api-replacement-for-the-iphone/ ) but the example provided is very different than what I need.
I am using OpenFlow in a horizontal view inside a navbar view controller. I have OpenFlow working already. I can scroll through all my images and works really good. However I am using it with over 100 images and it takes a while to load at first. In looking into performance improvements I realized the AFOpenFlowViewDataSource delegate is not getting called. I was able to get AFOpenFlowViewDelegate working by specifying the delegate in the view controller class "flowView.dataSource = self;". But I am not able to get the datasource delegate working. Not even with "flowView.viewDelegate = self;".
Is the datasource needed at all? It seems it is needed for threading of loading.
Ok, it looks like it is running beautiful now. The DataSource delegate is only called when there the objects are loaded dynamically. Meaning, if I use "[(AFOpenFlowView *)self.view setImage]" then dataSOurce is never called because all it knows images are already loaded. However, using "[(AFOpenFlowView *)self.view setNumberOfImages:30];" triggers the DataSource delegate to load the images as they are needed. I found the GetImageOperation NSThread very useful for my 100+ images. However, images are not unloaded after going offscreen. Anyone know how to unload images as they go off screen?