0

I am beginner in iOS In one of my activity I have created custom picker view with search bar .....Actually I am using YHCPicker class for custom picker view and search bar and apply this on TextField Code here.....

 UITextField* StateId;

 StateId=[[UITextField alloc]initWithFrame:CGRectMake(150,540,150,30)];
 StateId.font        = [UIFont boldSystemFontOfSize:12.0];
 StateId.borderStyle = UITextBorderStyleLine;

 StateId.delegate = self;
 StateId.tag      = 4;
 [scrollview addSubview:StateId];

and I am using this delegate for this textfield....

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    if (textField.tag==4)
    {
        View_StateID = [[NSMutable Array]allocinitWithArray:@"Delhi", @"Rajasthan"......, nil];
        NSLog(@"dict is %@",View_StateID);

        PickerView* objYHCPickerView = [[PickerView alloc] initWithFrame:CGRectMake(0, 0, 320, 480) ];

        objYHCPickerView.delegate = self;
        [self.view addSubview:objYHCPickerView];
        [objYHCPickerView showPicker:View_StateID];
    }
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
     [textField resignFirstResponder];
     return YES;
} 

then call method ShowPicker in YHCPickerView and I show this picker with search bar on my view.....like as image enter image description here

Now in this image when we search in search bar first time then get desired state successfully and click on done or search button(from keybord) then get value on StateID textfield but when we again tap on text field then my image as well as but tap on searchbar then get error like this....

 -[CALayer keyboardWillShowNotification:]: unrecognized selector sent to instance 0xaad8950

So I don't know what problem ....so solve this problem...

meaning-matters
  • 21,929
  • 10
  • 82
  • 142
Rahul Sharma
  • 940
  • 2
  • 12
  • 31

1 Answers1

0

Errors like this can be caused by non properly retaining objects:

  1. The object is released and freed.
  2. Its memory is reused for some random other object.
  3. Then, when a selector is called on the original object -> boom.

One thing to check is if all your @properties that hold objects in your class are strong and not assign.

What's also smart to do is setting an exception breakpoint

Finally, try to find out to which object this pointer 0xaad8950 (did) belong(s): Place breakpoints further and further, before the app crashes and look around at the objects' address you're having.

Good luck!

Community
  • 1
  • 1
meaning-matters
  • 21,929
  • 10
  • 82
  • 142