2016-09-05 9 views
0

Need to prevent this type of UI Interaction私はUIPickerを表示するテキストフィールドを持っています。ピッカーが最初のレスポンダを辞任した後、UIPickerから選択された項目がtextFieldに表示されます。しかし、私がUITextFieldを長く押すと、textFieldテキストを選択するオプションが与えられます。まだテキストフィールドとやりとりできるうちにUItextFieldテキストを選択できないようにする

いずれの回避策または解決策も高く評価されます。

UITextField *CatpickerField = [[UITextField alloc] initWithFrame:self.categoryView.bounds]; 
CatpickerField.backgroundColor = [UIColor clearColor]; 
[[CatpickerField valueForKey:@"textInputTraits"] setValue:[UIColor clearColor] forKey:@"insertionPointColor"]; 


CatpickerField .textAlignment = NSTextAlignmentRight; 
CatpickerField.text= @"Category"; 
UIPickerView * pickerCAt = [UIPickerView new]; 
pickerCAt.backgroundColor = [UIColor whiteColor]; 
pickerCAt.tag=1001; 
pickerCAt.delegate = self; 
pickerCAt.dataSource = self; 
pickerCAt.showsSelectionIndicator = NO; 

UIToolbar *toolBarcat= [[UIToolbar alloc] initWithFrame:CGRectMake(0,0,320,44)]; 
[toolBar1 setBarStyle:UIBarStyleBlack]; 
UIBarButtonItem *buttonCancelcat=[[UIBarButtonItem alloc]initWithTitle:@"Cancel" style:UIBarButtonItemStylePlain target:self action:@selector(barButtonCancelAction:)]; 
UIBarButtonItem *buttonDonecat=[[UIBarButtonItem alloc]initWithTitle:@"Done" style:UIBarButtonItemStylePlain target:self action:@selector(barButtonAction:)]; 
UIBarButtonItem *flexiblecat = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; 
toolBarcat.items = [NSArray arrayWithObjects:buttonCancelcat,flexiblecat,buttonDonecat,nil]; 

CatpickerField.inputView = pickerCAt; 
CatpickerField.inputAccessoryView = toolBar1; 

self.CatPickerviewField = CatpickerField; 
[self.categoryView addSubview:self.CatPickerviewField]; 

1

答えて

0

のUITextFieldにLongPressGestureRecognizerを追加します。

UILongPressGestureRecognizer *lpgr 
    = [[UILongPressGestureRecognizer alloc] 
       initWithTarget:self action:@selector(enableTextField)]; 
lpgr.delegate = self; 
lpgr.delaysTouchesBegan = YES; 
[self.textField addGestureRecognizer:lpgr]; 

とそれを扱う:

-(void)enableTextField 
    { 
    textField.enabled = YES; 
    } 
関連する問題