2013-03-05 97 views
4

scollview显示在文本的顶部和后面绘制文本如何克服此问题。下面是代码当我在alertview上添加textview时,将TextView添加到UIAlertView

问题更新:

如果设定textView.editable = NO;它工作正常,但在我的情况下,我需要在textview中键入文本。

UITextView *textView = [[UITextView alloc]initWithFrame:CGRectMake(12, 50, 260, 50)]; 

    [textView setText:@"lashdasjh asdasjdas asdlajsdl adsjajadsd aslj daj sdjasdjasjdlasjd as dlasj d"]; 

    UIAlertView *av = [[UIAlertView alloc]initWithTitle:@"Type Your Message" message:@"\n\n\n\n\n\n" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Send",nil]; 

    av.alertViewStyle = UIAlertViewStyleDefault; 

    [av addSubview:textView]; 

    [av show]; 

enter image description hereenter image description here

+1

http://stackoverflow.com/questions/9060310/how-to-add-textview- 320460-uialertview-iphone – Rushabh 2013-03-05 07:13:13

+0

我会认为12会是一个更大的数字 – 2013-03-05 07:13:24

+0

+1注意,似乎很奇怪。 – doge 2013-03-05 07:18:01

回答

4

解决自己。在消息删除@"\n\n\n\n\n\n"和标题

enter image description here

+1

添加屏幕截图在你回答 – Hari1251 2013-03-05 07:42:05

+0

很好。谢谢。这让我疯狂! – 2013-06-02 18:33:52

-1

添加@"\n\n\n\n\n\n"与此代码的工作精细取代你的代码。

UITextView *textView = [[UITextView alloc]initWithFrame:CGRectMake(12, 50, 260, 100)]; 

UIAlertView *av = [[UIAlertView alloc]initWithTitle:@"Type Your Message" message:@"\n\n\n\n\n" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Send",nil]; 

av.alertViewStyle = UIAlertViewStyleDefault; 

[av addSubview:textView]; 

[av show];