gpt4 book ai didi

ios - ActionSheetStringPicker Picker View 的 UITextView 问题

转载 作者:行者123 更新时间:2023-12-01 16:08:33 26 4
gpt4 key购买 nike

Here are the screenshots.

首先在这里查看 3 个屏幕截图。

屏幕截图 1:主题是 UITextview 字段。当我点击主题文本字段时,会出现普通键盘。现在这里没有问题。

屏幕截图 2:优先级是 UITextfield View 。这里我使用 UIActionsheet Picker View 。当我单击优先级文本字段选择器时,将出现如屏幕截图所示。这也工作正常。

我的问题 :当我通过滚动直接从主题 TextView 单击优先级文本字段时,不使用键盘上的完成按钮或下一步按钮。然后下一个问题来了。

或者当我将 UITextview 移动到其他任何其他文本字段时,例如帮助主题文本字段或源文本字段(在此文本字段中使用 UIActionsheet。)同样的问题出现了。

请参见屏幕截图 3。

在这里,keyboard 和 UIActionsheet 都出现了。这里键盘没有隐藏,它仍然出现。它不会出现在这里,当我将 UITextView 移动到下一个文本字段时,即在 UIActionsheet 选择器中,它只显示 Picker VIew。

我没有得到什么问题。任何人请告诉我解决方案。

这是一些代码,

@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

最佳答案

我认为以下IBAction代码:

- (IBAction)staffClicked:(id)sender {
[self.view endEditing:YES];
if (!_staffArray||!_staffArray.count) {
_assignTextField.text=NSLocalizedString(@"Not Available",nil);
staff_id=0;
}else{

[ActionSheetStringPicker showPickerWithTitle:NSLocalizedString(@"Select Assignee",nil) rows:_staffArray initialSelection:0 target:self successAction:@selector(staffWasSelected:element:) cancelAction:@selector(actionPickerCancelled:) origin:sender];
}
}

...以及以下方法:
- (void)staffWasSelected:(NSNumber *)selectedIndex element:(id)element
{
staff_id=(staff_idArray)[(NSUInteger) [selectedIndex intValue]];
self.assignTextField.text = (_staffArray)[(NSUInteger) [selectedIndex intValue]];
}


- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
return NO;
}

...将为您解决您的问题。

关于ios - ActionSheetStringPicker Picker View 的 UITextView 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46520850/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com