2012年8月2日木曜日

回転は続く

次はchat。UILabelを使ってたけどUITextViewに変更。ていうかなんでUILabel使ったんやろ。縦幅制限したい場合は→UILabel、それ以外はUITextViewでいいんじゃないの。ただautoresizingMaskでtextのframeは変わるけどdialogueごとに入れてる線のyは可変にはできないから再描画or2viewの切替が必要。結局link同様切替にした。answerも同じ理由で切替が必要かな。とりあえずchatのみ修正。回転検知後のメソッドもちょっと変えた。

SinglePost2.m
}else if([type isEqualToString:@"chat"]){
  if(![cont isEqual:[NSNull null]]){
   for(int pl=0;pl<2;pl++){
    CGFloat npy=0;int j=1;
    UIScrollView *chatScr=[[UIScrollView alloc]initWithFrame:CGRectMake(0,30,pl?sh:sw,(pl?sw:sh)-50)];[self.view addSubview:chatScr];
    UIView *chatBase=[[UIView alloc]initWithFrame:CGRectMake(0,0,pl?sh:sw,pl?sw:sh)];
    for(id dialogue in cont){
     UITextView *npv=[[UITextView alloc]initWithFrame:CGRectMake(20,npy,(pl?sh:sw)-40,0)];
     npv.text=[NSString stringWithFormat:@"%@%@",[dialogue objectForKey:@"label"],[dialogue objectForKey:@"phrase"]];npv.font=sf(15);
     npv.textColor=[UIColor blackColor];npv.backgroundColor=[UIColor clearColor];npv.editable=NO;[chatBase addSubview:npv];
     CGRect f=npv.frame;f.size.height=npv.contentSize.height;npv.frame=f;
     npy+=npv.contentSize.height+10;j++;
     UIImage *line=[UIImage imageNamed:@"gray"];
     UIImageView *linev=[[UIImageView alloc]initWithImage:line];linev.alpha=0.7;[linev setFrame:CGRectMake(25,npy-8,(pl?sh:sw)-50,4)];
     UIImage *fuki=[UIImage imageNamed:j%2?@"fuki":@"fuki2"];
     UIImageView *fukiv=[[UIImageView alloc]initWithImage:fuki];fukiv.alpha=0.7;
     [fukiv setFrame:CGRectMake(j%2?5:(pl?sh:sw)-fuki.size.width-5,npy-8-fuki.size.height,fuki.size.width,fuki.size.height)];
     [chatBase addSubview:linev];[chatBase addSubview:fukiv];[chatBase setTag:(pl?4000000:3000000)+now];
     [chatScr addSubview:chatBase];
     if(UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation)){if(!pl)chatBase.hidden=YES;}
     else if(pl)chatBase.hidden=YES;
    }
    [chatScr setContentSize:CGSizeMake((pl?sh:sw)-40,npy)];
   }
  }
 }
rootのvc
-(void)refpost{
 int plid;
 if([[typeArr objectAtIndex:now-1]isEqual:@"link"]) plid=1000000;
 else if([[typeArr objectAtIndex:now-1]isEqual:@"chat"]) plid=3000000;
 if(UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation)){
  [self.view viewWithTag:plid+now].hidden=YES;
  [self.view viewWithTag:plid+1000000+now].hidden=NO;
 }else{
  [self.view viewWithTag:plid+now].hidden=NO;
  [self.view viewWithTag:plid+1000000+now].hidden=YES;
 }
}
できた。ていうかここまで書いて気付いたけどUITextViewに線と吹き出し貼ったらautoresizingMask効くかな?あとで確認する。残すはaudio,video,answer。いけるやろ。
最近ラーメンは昼じゃなく夜食べるようにしたけど結局 並野菜マシマシ背脂ちょいマシカラメ@マッチョになる。今日も行ってきた。取り憑かれてんのかな。

0 件のコメント:

コメントを投稿