Iphone UIAlertView子类中的UITextView
我试图将UITextView放在UIAlertView的自定义子类中,该子类是我使用我的背景图像创建的。UITextView仅用于显示大量文本(因此滚动)。 这是我的子类的代码Iphone UIAlertView子类中的UITextView,iphone,uiview,uitextview,uialertview,Iphone,Uiview,Uitextview,Uialertview,我试图将UITextView放在UIAlertView的自定义子类中,该子类是我使用我的背景图像创建的。UITextView仅用于显示大量文本(因此滚动)。 这是我的子类的代码 - (id)initNarrationViewWithImage:(UIImage *)image text:(NSString *)text{ if (self = [super init]) { self.backgroundImage = image; UITextVie
- (id)initNarrationViewWithImage:(UIImage *)image text:(NSString *)text{
if (self = [super init]) {
self.backgroundImage = image;
UITextView * textView = [[UITextView alloc] initWithFrame:CGRectZero];
self.textualNarrationView = textView;
[textView release];
self.textualNarrationView.text = text;
self.textualNarrationView.backgroundColor = [UIColor colorWithRed:0.0 green:1.0 blue:0.0 alpha:1.0];
self.textualNarrationView.opaque = YES;
[self addSubview:textualNarrationView];
}
return self;
}
- (void)drawRect:(CGRect)rect {
NSLog(@"DRAU");
CGSize imageSize = self.backgroundImage.size;
[self.backgroundImage drawInRect:CGRectMake(0, 0, imageSize.width, imageSize.height)];
}
- (void)layoutSubviews {
CGSize imageSize = self.backgroundImage.size;
self.textualNarrationView.bounds = CGRectMake(0, 0, imageSize.width - 20, imageSize.height - 20);
self.textualNarrationView.center = CGPointMake(320/2, 480/2);
}
- (void)show{
[super show];
NSLog(@"SCIO");
CGSize imageSize = self.backgroundImage.size;
self.bounds = CGRectMake(0, 0, imageSize.width, imageSize.height);
self.center = CGPointMake(320/2, 480/2);
}
这是我第一次对UIView进行子类化,我肯定遗漏了一些东西,因为背景图像显示正确,UITextview也正确,但在几分之一秒后,它跳了起来(似乎是坐标问题).我终于创建了自己定制的
UIAlertView
版本,并在其中提供了一个UITextView
。是什么让我这么做的
当我尝试将UITextView
作为子视图附加到背景UIImageView
时,我经历了一种奇怪的行为,它不再响应触摸,使其按预期工作的方法是将其附加到基本视图并实现以下方法
-(BOOL)手势识别器:(UIGestureRecognizer*)手势识别器
应使用GestureRecognitor同时识别:(UIGestureRecognitor*)其他GestureRecognitor
如果我没有弄错,UIAlert会在屏幕上有太多文本的情况下自动添加UITextView…那么在初始化时我应该在哪里添加文本?目前我使用UILabel选择了另一个方向。如果我找到了,我会发布一个解决方案