如何将光标位置固定在UITextView的左下角?

时间:2011-07-22 07:05:50

标签: iphone objective-c xcode cocoa-touch

我知道这可能是一个有趣的问题,但我仍然遇到问题,因为我是iphone的新手。 问题 - >实际上我正在单元格中创建自定义textview并在键盘出现时上下查看。所以我得到的问题是当textViewShouldBeginEditing调用并且我的视图向上时,textview的光标也向上并隐藏光标,我无法看到我在textview中写的文本。 我在UITableView中编写此代码:

UITextView *_RepliesPost = [[UITextView alloc] initWithFrame:CGRectMake(5, 2, 260, 32)];
                _RepliesPost.textAlignment = UITextAlignmentLeft;
                _RepliesPost.font = [UIFont fontWithName:@"Helvetica neue" size:6.00];
                _RepliesPost.font = [UIFont boldSystemFontOfSize:10];
                _RepliesPost.tag=15;
                _RepliesPost.delegate=self;
                _RepliesPost.backgroundColor = [UIColor whiteColor];
                _RepliesPost.textColor = [UIColor blackColor];
                [cell.contentView addSubview:_RepliesPost];

所以请帮我解决这个问题,,,提前谢谢。

1 个答案:

答案 0 :(得分:0)

尝试将UITextView添加为附件视图,而不是内容视图。像这样:

[cell setAccessoryView:_RepliesPost];

编辑时仍然可见。我还喜欢在执行此操作时将我的UITextView对齐设置为UITextAlignmentRight,因为它看起来最美观。