Is one of your allocations falling out of scope and being cleaned up by ARC?
Helpful link on how the responder chain works..
Question
I have a custom class like this:
@interface formParser : NSObject <UITextFieldDelegate> {
....
and in the .m I create a UITextField element like this:
UITextField *ui = [[UITextField alloc] initWithFrame:CGRectMake(left, top, width, height)];
[ui setDelegate:self];
[ui setPlaceholder:[dict_elementInfo objectForKey:@"placeholder"]];
[ui setBorderStyle:UITextBorderStyleLine];
[view addSubview:ui];
and
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
NSLog(@"should begin");
return NO;
}
My problem is that the shouldbegin is never called. When I try this technique on a "normal" UIViewController class it works perfectly, but doing this in my custom object it it never called.. Can anyone figure out why?
My custom class is called as follows:
formParser *fParse = [[formParser alloc] init];
UIView *view_formBackground = [fParse viewOfPlist:@"form" initSize:CGRectMake(0, 0, scrollView.contentSize.width, scrollView.contentSize.height)];
view_formBackground.backgroundColor = [UIColor whiteColor];
//add views to main view
[scrollView addSubview:view_formBackground];
[self.view addSubview:scrollView];
Also, in formparser.m the viewofplist is as follows:
-(UIView *)viewOfPlist:(NSString *)filename initSize:(CGRect)size
{
ypos_element_left = 40; ypos_element_right = 40;
view = [[UIView alloc] initWithFrame:size];
//load plist
NSString *path = [[NSBundle mainBundle] pathForResource:filename ofType:@"plist"];
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:path];
rootArray = [dict objectForKey:@"form"];
//loop door alle UI entries in de dict.
for (NSDictionary *dict_UIElement in rootArray)
{
NSString *UIType = [dict_UIElement objectForKey:@"type"];
if ([UIType isEqualToString:@"ui_empty"]) [self handle_uiempty:dict_UIElement];
if ([UIType isEqualToString:@"ui_multiselect"]) [self handle_uimultiselect:dict_UIElement];
if ([UIType isEqualToString:@"ui_label"]) [self handle_uilabel:dict_UIElement];
if ([UIType isEqualToString:@"ui_textfield"]) [self handle_uitextfield:dict_UIElement];
if ([UIType isEqualToString:@"ui_choicefield"]) [self handle_uichoicefield:dict_UIElement];
if ([UIType isEqualToString:@"ui_calendar"]) [self handle_uicalendar:dict_UIElement];
}
return (view);
}
Thanks for answering!
Solution
Is one of your allocations falling out of scope and being cleaned up by ARC?
Helpful link on how the responder chain works..