开发者

UITextView in a UITableViewCell: first responder problem

开发者 https://www.devze.com 2023-03-10 14:54 出处:网络
I have a UITextView in a UITableViewCell which grows together with it. Using [myTableView beginUpdates];

I have a UITextView in a UITableViewCell which grows together with it. Using

[myTableView beginUpdates];
[myTableView endUpdates];

in textViewDidChange and setting the height of the cell properly, I'm getting close to the solution. But I've a problem tied to the first responder. I set the textview in my custom cell to become the first responder ('cause I want to start with the open keyboard) on开发者_高级运维 the view loading, but the textview is nil in viewDidLoad, viewWillAppear, viewDidAppear, only when I write a char I can see it's not nil.

I connected the textview in the IB custom cell with an IBOutlet in my viewcontroller.


I resolved putting

[myTextView becomeFirstResponder];

in

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
0

精彩评论

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