I have some dynamically allocated texfields and in which i am entering the text,
Now i have got two problems here
1) After 2-3 button clicks, i mean changing the views and coming back to the same view than the data is not being removed from the textfield the previous data in the textfield is being present.
the code i have tried with are
answerTextField.text = @"";
answerTextField.text = nil;
2) I am unable to delete the textfield data in which i am appending the data that is coming from the textfield.text
-(void) keyPressed: (NSNotification*) notification {
if ([[[notification object]text] isEqualToString:@" "])
{
UITextField *textField = (UITextField *)[self.view viewWithTag:nextTag];
textField.text = @"";
[textField becomeFirstResponder];
nextTag = textField.tag;
}
else
{
[[NSNotificationCenter defaultCenter] removeObserver: self name:UITextFieldTextDidChangeNotification object: nil];NSLog(@"TextField tag value :%d",tagCount);
NSLog(@"TextField next tagg tag value :%d",nextTag);
if (tagCount == nextTag+1)
{
UITextField *textField = (UITextField *)[self.view viewWithTag:nextTag];
[textField resignFirstResponder];
NSLog(@"append string :%@",appendString);
}
else
{
NSLog(@"TextField nexttag value before :%d",nextTag);
nextTag = nextTag + 1;
NSLog(@"Letter is%@",[[notification object]text]);
str= [[NSString alloc]initWithFormat:@"%@",[[notification object]text]];
NSLog(@"TextField String :%@",str);
NSLog(@"TextField nexttag value after :%d",nextTag);
[appendString appendString:[NSString stringWithFormat:@"%@",str]];
NSLog(@"Content in MutableString: %@",appendString);
}
NSLog(@"The tags in keypressed:%d",nextTag);
UITextField *textField = (UITextField *)[self.view viewWithTag:nextTag];
[textField becomeFirstResponder];
}
// For inserting Spaces taken from array.
if(tagCount+300 == nextTag)
{
for (int m=0 ; m< [intArray count]; m++)
{
[appendString insertString:@" " atIndex:[[intArray objectAtIndex:m]intValue]];
NSLog(@"FinalString : %@",appendString);
}
}
}
No comments:
Post a Comment