UIButtonの上に、UITextViewを配置したら、
UIButtonに設定したアクションが効かなくなってしまった。 
それもそのはず、UITextViewが一番上の層にあるので、
それが邪魔をしてUIButtonが反応しないのだ。 
そんな時は、
ボタンの色を透明に設定してあげれば大丈夫。
 (なんですぐに気づかなかったんだろう、、)
 -----
//ボタンを設置する(アクションはshow_view1を設定)
  
self.view1 = [[UIButton buttonWithType:UIButtonTypeCustom] retain]; self.view1.frame = CGRectMake(10, 10, 300, 60);
self.view1.backgroundColor = [UIColor clearColor];
 [self.view1 addTarget:self action:@selector(show_view1:) forControlEvents:UIControlEventTouchUpInside];
 [self.wv insertSubview:view1 atIndex:2];  //テキストビューを配置する
  
self.lbl1 = [[UITextView alloc] initWithFrame:CGRectMake(90, 10, 220.0, 60.0)];
 self.lbl1.font = [UIFont fontWithName:@"HiraKakuProN-W6" size:14];
 self.lbl1.textAlignment = UITextAlignmentLeft;
 self.lbl1.editable = NO;
 self.lbl1.scrollEnabled = NO;
 self.lbl1.userInteractionEnabled = NO;
 self.lbl1.textColor = [UIColor colorWithRed:72/256.0 green:88/256.0 blue:89/256.0 alpha:1.0f];  
self.lbl1.backgroundColor =[UIColor whiteColor];
 self.lbl1.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight;
 self.lbl1.text = @"あsdふあsdふぁsdふぁsdふぁsdふぁsだsdf";
 [self.wv insertSubview:lbl1 atIndex:1];
 ----
 これでボタンもしっかり反応させることが出来ましたー!!
 
0 件のコメント:
コメントを投稿