开发者

Can't type in UITextFiled when placed in UIActionSheet

开发者 https://www.devze.com 2023-04-02 00:20 出处:网络
A button triggers a function that creates a UIActionSheet. Looks like this: reportSheet = [[UIActionSheet alloc]

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];
0

精彩评论

暂无评论...
验证码 换一张
取 消