2012-01-30 50 views
1

我在UIAlertView开始时显示了EULA,其中有Accept按钮。我已成功地按照Problem with opning the page (License agreement page)的链接回答了问题。如何在UIAlertView中添加TextView 320 * 460 iPhone

我只是想表明在开始6页EULA的,但我无法显示具有Alertview EULA内容全尺寸的TextView /滚动视图。任何人都可以建议我正确的方式。提前致谢。

+0

如何将这样一个巨大的文本视图放入警报视图?只需将文本转储到警报视图中并让它以自己的方式呈现,或使用模式视图控制器。 – BoltClock 2012-01-30 06:49:50

+0

如果我们能在alertView显示tableview中......那么为什么不滚动的TextView? – 2012-01-30 06:52:12

+1

为什么您需要在警报视图提供自己的实现?正如我所说的,只需将警报视图的消息设置为文本,它就会处理它。 – BoltClock 2012-01-30 06:53:57

回答

2

您可以制作任意大小的alertView并添加任何大小的自定义TextView。使用代码snippiest

- (void) doAlertViewWithTextView { 

UIAlertView *alert = [[UIAlertView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)]; 

alert.title = nil; 
alert.message = nil; 
alert.delegate = self; 
[alert addButtonWithTitle:@"Cancel"]; 
[alert addButtonWithTitle:nil]; 

UITextView *textView = [[UITextView alloc] initWithFrame:alert.bounds]; 
textView.text = @"This is what i am trying to add in alertView.\nHappy New Year Farmers! The new Winter Fantasy Limited Edition Items have arrived! Enchant your orchard with a Icy Peach Tree, and be the first farmer among your friends to have the Frosty Fairy Horse. Don't forget that the Mystery Game has been refreshed with a new Winter Fantasy Animal theme! "; 
textView.keyboardAppearance = UIKeyboardAppearanceAlert; 
textView.editable = NO; 
[alert addSubview:textView]; 
[textView release]; 

[alert show]; 
[alert release]; 

}

但通过使alertView的大小等于整个iPhone的屏幕尺寸,你将失去取消按钮。

也可以使用这种委托方法。

- (void)willPresentAlertView:(UIAlertView *)alertView { 

[alertView setFrame:CGRectMake(0, 0, 320, 460)];} 
+0

肯定。它的工作,但我想说明接受与在拒绝下面的TextView的按钮。现在它不是看起来很不错。警报和TextView的屏幕尺寸的任何建议,使其适合,因为我需要... – 2012-01-30 08:56:55

+0

为了这个目的,你必须减少TextView的尺寸或使从alertView继承的类,并自定义按钮。 – fibnochi 2012-01-30 11:53:50

+0

无法看清iOS8上的iPad TextView的 – Gank 2015-05-21 03:10:45