Я пытаюсь вызвать -(BOOL) textFieldShouldClear:(UITextField *)textField
при нажатии кнопки очистки UITextField. Я уже установил свой делегат, и другие методы делегата UITextField вызываются правильно, кроме этого. Кнопка «Очистить» настроена на «всегда видна» в файле пера.
ИЗМЕНИТЬ
К вашему сведению, я показываю FPPopover при изменении текста текстового поля. если я нажимаю кнопку очистки, не показывая всплывающее окно, кнопка очистки работает нормально. Но если я попытаюсь коснуться его, когда отображается всплывающее окно, метод делегата не вызывается.
Фрагмент кода
-(BOOL) textFieldShouldClear:(UITextField *)textField
{
return YES;
}
- (IBAction)didChangeScripText:(id)sender {
NSString *text = isPortrait ? symbolTextField.text : landsymbolTextfield.text;
if(scripList.count == 0)
{
if([Logs sharedManager].scripData.count > 0)
[self extractScrips];
else
return;
}
// SAFE_ARC_RELEASE(popover);
// popover=nil;
//the controller we want to present as a popover
if(controller == nil)
controller = [[scripComboViewController alloc] initWithStyle:UITableViewStylePlain];
if(controller.scripListFiltered.count > 0)
[controller.scripListFiltered removeAllObjects];
controller.delegate = self;
if(popover == nil){
popover = [[FPPopoverController alloc] initWithViewController:controller];
popover.tint = FPPopoverDefaultTint;
}
controller.scripListFiltered = [NSMutableArray arrayWithArray:[scripList filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF beginswith[c] %@",text]]];
NSLog(@"array is: %@",controller.scripListFiltered);
if(controller.scripListFiltered.count == 0)
{
[popover dismissPopoverAnimated:YES];
return;
}
//decide contentsize and arrow dir based on tableview height
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
popover.contentSize = CGSizeMake(300, 500);
}
else {
popover.contentSize = CGSizeMake(200, 200);
}
//sender is the uitextfield
float height = isPortrait ? portTable.frame.size.height : landTable.frame.size.height;
if(height > 0)
popover.arrowDirection = FPPopoverArrowDirectionDown;
else
popover.arrowDirection = FPPopoverArrowDirectionUp;
if(![popover isModalInPopover])
[popover presentPopoverFromView:sender];
[controller reloadTable];
}
Что происходит не так? Может ли кто-нибудь сказать мне. Спасибо.