Save temporary values deleted by reloadData in a UITableView
up vote
0
down vote
favorite
I have a simple project with UITableViewCell
, inside the Cell I have a UITextField
, In my case I am creating rows of a table dynamically, ie:
When I call function 'AddField' There is a counter that is responsible for storing the number of rows that the table must have.
-(void)AddField{
numberOfRows++;
[tableView reloadData];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return numberOfRows;
}
So, if I type something in the first text field and then call the function to add more rows in the table, the row is added, another text field appear (leaving two), but the text entered in the first text field disappears due the command reloadData
.
I Need help find the best way around this problem, any suggestions?
objective-c uitableview
add a comment |
up vote
0
down vote
favorite
I have a simple project with UITableViewCell
, inside the Cell I have a UITextField
, In my case I am creating rows of a table dynamically, ie:
When I call function 'AddField' There is a counter that is responsible for storing the number of rows that the table must have.
-(void)AddField{
numberOfRows++;
[tableView reloadData];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return numberOfRows;
}
So, if I type something in the first text field and then call the function to add more rows in the table, the row is added, another text field appear (leaving two), but the text entered in the first text field disappears due the command reloadData
.
I Need help find the best way around this problem, any suggestions?
objective-c uitableview
have you considered usinginsertRowsAtIndexPaths:withRowAnimation:
rather than handling it yourself?
– chetem
May 19 '14 at 17:35
I will try this soon!
– user3613119
May 19 '14 at 18:20
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a simple project with UITableViewCell
, inside the Cell I have a UITextField
, In my case I am creating rows of a table dynamically, ie:
When I call function 'AddField' There is a counter that is responsible for storing the number of rows that the table must have.
-(void)AddField{
numberOfRows++;
[tableView reloadData];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return numberOfRows;
}
So, if I type something in the first text field and then call the function to add more rows in the table, the row is added, another text field appear (leaving two), but the text entered in the first text field disappears due the command reloadData
.
I Need help find the best way around this problem, any suggestions?
objective-c uitableview
I have a simple project with UITableViewCell
, inside the Cell I have a UITextField
, In my case I am creating rows of a table dynamically, ie:
When I call function 'AddField' There is a counter that is responsible for storing the number of rows that the table must have.
-(void)AddField{
numberOfRows++;
[tableView reloadData];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return numberOfRows;
}
So, if I type something in the first text field and then call the function to add more rows in the table, the row is added, another text field appear (leaving two), but the text entered in the first text field disappears due the command reloadData
.
I Need help find the best way around this problem, any suggestions?
objective-c uitableview
objective-c uitableview
edited Nov 11 at 6:46
Cœur
17k9102140
17k9102140
asked May 19 '14 at 17:05
user3613119
495
495
have you considered usinginsertRowsAtIndexPaths:withRowAnimation:
rather than handling it yourself?
– chetem
May 19 '14 at 17:35
I will try this soon!
– user3613119
May 19 '14 at 18:20
add a comment |
have you considered usinginsertRowsAtIndexPaths:withRowAnimation:
rather than handling it yourself?
– chetem
May 19 '14 at 17:35
I will try this soon!
– user3613119
May 19 '14 at 18:20
have you considered using
insertRowsAtIndexPaths:withRowAnimation:
rather than handling it yourself?– chetem
May 19 '14 at 17:35
have you considered using
insertRowsAtIndexPaths:withRowAnimation:
rather than handling it yourself?– chetem
May 19 '14 at 17:35
I will try this soon!
– user3613119
May 19 '14 at 18:20
I will try this soon!
– user3613119
May 19 '14 at 18:20
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Have a Mutable array to store all the typed values.
[self.myMutableArray addObject:cell.textField.text];
In cell for Row at index path, get the text and set it back to the text field.
cell.textField.text = self.myMutableArray[indexPath.row]
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Have a Mutable array to store all the typed values.
[self.myMutableArray addObject:cell.textField.text];
In cell for Row at index path, get the text and set it back to the text field.
cell.textField.text = self.myMutableArray[indexPath.row]
add a comment |
up vote
0
down vote
Have a Mutable array to store all the typed values.
[self.myMutableArray addObject:cell.textField.text];
In cell for Row at index path, get the text and set it back to the text field.
cell.textField.text = self.myMutableArray[indexPath.row]
add a comment |
up vote
0
down vote
up vote
0
down vote
Have a Mutable array to store all the typed values.
[self.myMutableArray addObject:cell.textField.text];
In cell for Row at index path, get the text and set it back to the text field.
cell.textField.text = self.myMutableArray[indexPath.row]
Have a Mutable array to store all the typed values.
[self.myMutableArray addObject:cell.textField.text];
In cell for Row at index path, get the text and set it back to the text field.
cell.textField.text = self.myMutableArray[indexPath.row]
answered May 19 '14 at 17:44
Naveen Prasad R
1,84911016
1,84911016
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f23743385%2fsave-temporary-values-deleted-by-reloaddata-in-a-uitableview%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
have you considered using
insertRowsAtIndexPaths:withRowAnimation:
rather than handling it yourself?– chetem
May 19 '14 at 17:35
I will try this soon!
– user3613119
May 19 '14 at 18:20