0

A button triggers a function that creates a UIActionSheet. Looks like this:

reportSheet = [[UIActionSheet alloc] 
               initWithTitle:nil
               delegate:self
               cancelButtonTitle:nil 
               destructiveButtonTitle:nil
               otherButtonTitles:nil
               ];

[reportSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];

When i add a UITextField to this ActionSheet, I cant type any thing in it. The keyboard appears but when I press the buttons nothing happens. The marker just stands in position 0 and blink. This code looks like this:

newComment = [[UITextField alloc] initWithFrame:CGRectMake(10, 10, 300, 200)];
newComment.backgroundColor = [UIColor redColor];
newComment.delegate = self;
[reportSheet addSubview:newComment];
[newComment release];

If I add the TextField to self.view (instead of reportSheet above) it works fine and there's no problem to type in it.

Any ideas what's wrong here?

Rob Keniger
  • 45,830
  • 6
  • 101
  • 134
Linus
  • 1
  • You might have a look @ [iPhone UIActionSheet with UISwitch and UITextField](http://stackoverflow.com/questions/3654091/iphone-uiactionsheet-with-uiswitch-and-uitextfield) and [how to enable text input in UITextField which is in UIActionSheet?](http://stackoverflow.com/questions/5089437/how-to-enable-text-input-in-uitextfield-which-is-in-uiactionsheet) – Seb T. Aug 31 '11 at 12:36
  • I think there is a problem with the frame size of `UITextField` – Legolas Aug 31 '11 at 15:11

1 Answers1

3

Try

[newComment.layer addAnimation:[reportSheet.layer animationForKey:reportSheet.layer.animationKeys.lastObject] forKey:reportSheet.layer.animationKeys.lastObject];
 [[reportSheet superview] addSubview:newComment];
krock
  • 28,904
  • 13
  • 79
  • 85
DeadSnow
  • 31
  • 3