Sometimes, It is required to use same tableviewcontroller multiple times with different parameters. For example, in a game, we need to show same screen with different elements. Here, our object is to reuse UITableViewController with different parameters and it will be happened on navigation next button click.
Here are the simple steps to do this:
1. Declare all parameters which make changes in tableview in AppDelegate class.
2. Load all parameters/Data sources in applicationDidFinishLaunching method.
3. Add a UITableViewController class and add all required controls, methods and properties.
4. In init method of UITableViewController initialize appDelegate class object to access the parameters.
5. Now in following method loads control with the appDelegate's parameters value and add it in the cell view.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
...... Setup the cell ......
}
6. Process and Call [self loadView]; where you want to reload data with changes.
Suppose you need to set tableview according NSMutableArray and On next click, you need to show next element of NSMutableArray.
Then declare index parameter in AppDelegate class and use it in cellForRowAtIndexPath method. On next click, Increment the index value and reload using [self loadView]; It will call cellForRowAtIndexPath again for the next value.
Hope, It helps.
Reload Table View with different values iPhone
Tags:
iPhone,
Objective-C
Related Posts :
iPhone
- Pass parameters to web-service with image uploading in iphone
- Dynamic multiline label with custom font in UITableViewController
- Show UIImagePickerController from UITableViewController in iPhone
- Resize Image to scale for a given max dimension in iphone
- Generate random order of series in iphone
- Pass username and password to webservice in iphone
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment