Я пытаюсь вызвать -(BOOL) textFieldShouldClear:(UITextField *)textField
при нажатии кнопки очистки UITextField. Я уже установил свой делегат, и методы другого делегата UITextField вызывается правильно, кроме этого. Кнопка «Очистить» установлена на «всегда отображается» в файле nib.textfieldshouldclear: не вызывается UITextfield
EDIT
FYI Я показываю FPPopover, когда текст TextField был изменен. если я нажимаю на кнопку очистки без отображения popover, кнопка очистки работает нормально. Но если я попытаюсь использовать его, когда отображается popover, метод delegate не вызывается.
Код сниппета
-(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];
}
Что происходит не так? Может ли кто-нибудь сказать мне. Благодарю.
@Rahul появляется, но не выделяется при кране. – NightFury
Тогда, вероятно, ваше текстовое поле пересекает границы его надзора. Каким-то образом часть (включая четкую кнопку) вашего текстового поля может пересекать границы (рамки) родительского представления. Проверьте мой ответ: http://stackoverflow.com/questions/15331725/buttons-are-not-working-on-bottom-of-iphone5/15331793#15331793 –
опубликуйте фрагмент кода. – Singh