Can't type in UITextFiled when placed in UIActionSheet
A button triggers a function that creates a UIActionSheet. Looks like this:
reportSheet = [[UIActionSheet alloc]
initWithTitle:nil
delegate:self
cancelButtonTi开发者_如何转开发tle: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?
Try
[newComment.layer addAnimation:[reportSheet.layer animationForKey:reportSheet.layer.animationKeys.lastObject] forKey:reportSheet.layer.animationKeys.lastObject];
[[reportSheet superview] addSubview:newComment];
精彩评论