Check 3 screenshots here first.
Screenshot 1 : Subject is UITextview field. When I tap on subject text field normal keyboard will come. There is no problem here now.
Screenshot 2 : Priority is UITextfield view. Here I use UIActionsheet Picker view. When I click on Priority textfield picker will appear as shown in screenshot. This is also working fine.
My Problem : When I click Priority textfield directly from Subject textview by scrolling without using done button or next button from keyboard. Then following issue is arriving.
or when I move UITextview to other any other Text Field like in Help Topic Text Field or Source Text Field (In this text field UIActionsheet is used.) same problem is arriving.
See screenshot number 3.
here, keyboard and UIActionsheet both are appearing. Here keyboard is not hiding, it is still appearing. It will not appear here, when I move here UITextView to next Text Field i.e in UIActionsheet picker, it has show Picker VIew only.
What is the problem I am not getting. Anybody please tell me solution for that.
Here is some code for that,
@interface EditDetailTableViewController ()
{
NSNumber *help_topic_id;
NSNumber *priority_id;
NSMutableArray * pri_idArray;
NSMutableArray * helpTopic_idArray;
}
- (void)helpTopicWasSelected:(NSNumber *)selectedIndex element:(id)element;
- (void)priorityWasSelected:(NSNumber *)selectedIndex element:(id)element
- (void)actionPickerCancelled:(id)sender;
@end
@implementation EditDetailTableViewController
- (void)viewDidLoad {
[super viewDidLoad];
help_topic_id=[[NSNumber alloc]init];
priority_id=[[NSNumber alloc]init];
}
-(void)removeKeyBoard
{
[self.subjectTextView resignFirstResponder];
}
- (IBAction)priorityClicked:(id)sender {
[_priorityTextField resignFirstResponder];
if (!_priorityArray||![_priorityArray count]) {
_priorityTextField.text=NSLocalizedString(@"Not Available",nil);
priority_id=0;
}else{
[ActionSheetStringPicker showPickerWithTitle:@"Select Priority" rows:_priorityArray initialSelection:0 target:self successAction:@selector(priorityWasSelected:element:) cancelAction:@selector(actionPickerCancelled:) origin:sender];
}
}
- (IBAction)helpTopicClicked:(id)sender {
[_helpTopicTextField resignFirstResponder];
if (!_helptopicsArray||!_helptopicsArray.count) {
_helpTopicTextField.text=NSLocalizedString(@"Not Available",nil);
help_topic_id=0;
}else{
[ActionSheetStringPicker showPickerWithTitle:@"Select Helptopic" rows:_helptopicsArray initialSelection:0 target:self successAction:@selector(helpTopicWasSelected:element:) cancelAction:@selector(actionPickerCancelled:) origin:sender];
}
}
- (void)priorityWasSelected:(NSNumber *)selectedIndex element:(id)element {
priority_id=(pri_idArray)[(NSUInteger) [selectedIndex intValue]];
//self.selectedIndex = [selectedIndex intValue];
//may have originated from textField or barButtonItem, use an IBOutlet instead of element
self.priorityTextField.text = (_priorityArray)[(NSUInteger) [selectedIndex intValue]];
}
- (void)helpTopicWasSelected:(NSNumber *)selectedIndex element:(id)element {
help_topic_id=(helpTopic_idArray)[(NSUInteger) [selectedIndex intValue]];
// self.selectedIndex = [selectedIndex intValue];
//may have originated from textField or barButtonItem, use an IBOutlet instead of element
self.helpTopicTextField.text = (_helptopicsArray)[(NSUInteger) [selectedIndex intValue]];
}
#pragma mark - UITextFieldDelegate
- (void)textFieldDidBeginEditing:(UITextField *)textField {
if (textField.tag==1) {
[_priorityTextField resignFirstResponder];
_priorityTextField.tintColor = [UIColor clearColor];
if (!_priorityArray||![_priorityArray count]) {
_priorityTextField.text=NSLocalizedString(@"Not Available",nil);
priority_id=0;
}else{
[ActionSheetStringPicker showPickerWithTitle:@"Select Priority" rows:_priorityArray initialSelection:0 target:self successAction:@selector(priorityWasSelected:element:) cancelAction:@selector(actionPickerCancelled:) origin:self.view];
}
// return NO;
}else if(textField.tag==2){
//[_subjectTextField resignFirstResponder];
[_helpTopicTextField resignFirstResponder];
_helpTopicTextField.tintColor = [UIColor clearColor];
if (!_helptopicsArray||!_helptopicsArray.count) {
_helpTopicTextField.text=NSLocalizedString(@"Not Available",nil);
help_topic_id=0;
}else{
[ActionSheetStringPicker showPickerWithTitle:@"Select Helptopic" rows:_helptopicsArray initialSelection:0 target:self successAction:@selector(helpTopicWasSelected:element:) cancelAction:@selector(actionPickerCancelled:) origin:self.view];
}
// return NO;
}else{
}
// return YES;
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
//[textView resignFirstResponder];
if(textView == _subjectTextView)
{
if([text isEqualToString:@" "])
{
if(!textView.text.length)
{
return NO;
}
}
if([textView.text stringByReplacingCharactersInRange:range withString:text].length < textView.text.length)
{
return YES;
}
if([textView.text stringByReplacingCharactersInRange:range withString:text].length >100)
{
return NO;
}
NSCharacterSet *set=[NSCharacterSet characterSetWithCharactersInString:@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 "];
if([text rangeOfCharacterFromSet:set].location == NSNotFound)
{
return NO;
}
}
return YES;
}
@end