Thursday, 15 April 2010

ios - how to use the function dequeueReusableCellWithIdentifier:forIndexPath? -


I know that dequeueReusableCellWithIdentifier: forInexPath is called in tableview mode inside tableview controller and if I understand correctly Yes, the table view method is sometimes called until all cells are populated. But I do not know where to get the price for the parameter index?

Note: I already have my cell population, I want to use my dequeueReusableCellWithIdentifier: for IMEXPath is a method that I created because I To use cell you want to copy some values ​​of your properties. Which means that I have used the method table view successfully.

(edit) Additional information: I am trying to create a profile and edit the profile table view. Inside the profile table view, I displayed the user's name, address, contact # etc. In addition, I have a Segue called Editing Profile in the profile, I have textfield for each category (name, address, etc.). What I want to do is, if I edit the content of the textfield, then I Be able to display new content in your profile tableview. An example would be a case: I am displaying in the profile view -> Name: Human, Address: Earth (each in its own cell). Now if I go to editofofile tableview, then I will edit that content -> Name: Alien, Address: Mars. After this, there is a button called 'Apply' to finish editing the content and the profile goes back to the table view. If I go back to the profile view, the display should now be named: Foreign, Address: Mars and Name no: Human, Address: Earth.

This is some code if it is a help code is called a button in the table view controller "MySell" is the square of my cell. This code is not working properly. I hope someone can help me fix this.

  - (IBAction) update code: (ID) sender {static NSString * ident = @ "MyCell"; NSIndexPath * indexPath; // MyCell to create a cell * cell = [self.tableView dequeueReusableCellWithIdentifier: ident forIndexPath: indexPath]; // variable to create variables for entry rows = [index line]; _labelValues ​​[row] = cell.textField.text  

}

You should only use dequeueReusableCellWithIdentifier , when you have to provide the table view with the cell display. If you want to get the UITableViewCell object in a certain index, then you should use.

Your problem

Do you really need a model class. You can then pass it on the Edit Controller, which changes the properties, then when you return to the tableView, you can load it again and display new properties.

You can also create a representative protocol for the Edit Your Profile Administrator, with something like EditProfileViewControllerDelegate :

  Protocol EditProfileViewControllerDelegate {- (Zero) editProfileViewController: (EditProfileViewController *) Administrator didUpdateName: (NSString *) Name Address: (NSString *) address; }  

You can apply this rep in your table view controller and use it to update the values ​​when the text has changed. Nonetheless, it quickly gets unwieldy, I would not recommend this when using a proper model class.


No comments:

Post a Comment