私はUITableView
自分のXIBにいます。今、私はこれに2つの向きの問題があります。
1)サブビューとしてをに追加UIImageView
しました。各テーブルセルにその画像とラベルが必要なので。そして、このために私はで位置を定義しました。しかし、ビューを横向きに回転させようとすると、で位置を変更した場合でも、これらの画像とラベルが前述したのと同じ位置に表示されます。なぜこれが起こるのですか?とこの問題を修正する方法は?これが私のコードです、UILabel
cell.contentview
CellforRowAtIndexPath
WillRotateOrientation
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
imgView1 = [[UIImageView alloc] initWithFrame:CGRectMake(680, 60, 40, 40)];
[imgView1 setImage:[UIImage imageNamed:@"Downloaded.png"]];
if([[[appDelegate selectDB] valueForKey:@"bookname"] containsObject:[listOfBooks objectAtIndex:indexPath.row]] )
{
[cell.contentView addSubview:imgView1];
}
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[self handleInterfaceRotationForOrientation:toInterfaceOrientation];
if (toInterfaceOrientation==UIInterfaceOrientationLandscapeRight)
{
imgView1.frame = CGRectMake(890,0, 40, 40);
}
else if (toInterfaceOrientation==UIInterfaceOrientationLandscapeLeft)
{
imgView1.frame = CGRectMake(890,0, 40, 40);
}
else if (toInterfaceOrientation==UIInterfaceOrientationPortrait)
{
imgView1.frame = CGRectMake(690, 60, 40, 40);
}
else
{
imgView1.frame = CGRectMake(690, 60, 40, 40);
}
//ここでは、画像ビューコードのみを追加しました。
2)進行状況ビューとキャンセルボタンが1つあるアラートビューがあります。ポートレートからランドスケープ/ランドスケープからポートレートに回転しようとすると、アラートビューが悲鳴を上げて進行状況ビューを表示できず、キャンセルボタンのサイズが自動的に大きくなります。
- (void)willPresentAlertView:(UIAlertView *)alertView
{
if(alertView.tag == kAlertViewOne)
{
progressAlert.frame = CGRectMake(270, 380, 300, 200);
activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
activityView.frame = CGRectMake(139.0f-18.0f, 40.0f, 37.0f, 37.0f);
[progressAlert addSubview:activityView];
[activityView startAnimating];
DownloadingcancelButton=[(NSMutableArray*)[progressAlert valueForKey:@"_buttons"] objectAtIndex:0];
DownloadingcancelButton.frame=CGRectMake(70, 115, 150, 45);
}
else if(alertView.tag == kAlertViewTwo)
{
UIButton *cancelButton=[(NSMutableArray*)[redownloadAlert valueForKey:@"_buttons"] objectAtIndex:1];
cancelButton.frame=CGRectMake(150, 85, 80, 45);
UIButton *YESButton=[(NSMutableArray*)[redownloadAlert valueForKey:@"_buttons"] objectAtIndex:0];
YESButton.frame=CGRectMake(40, 85, 80, 45);
}
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[self handleInterfaceRotationForOrientation:toInterfaceOrientation];
if (toInterfaceOrientation==UIInterfaceOrientationLandscapeRight)
{
progressAlert.frame = CGRectMake(270, 380, 300, 250);
DownloadingcancelButton.frame=CGRectMake(70, 160, 150, 45);
}
else if (toInterfaceOrientation==UIInterfaceOrientationLandscapeLeft)
{
progressAlert.frame = CGRectMake(270, 380, 300, 250);
DownloadingcancelButton.frame=CGRectMake(70, 160, 150, 45);
}
else if (toInterfaceOrientation==UIInterfaceOrientationPortrait)
{
progressAlert.frame = CGRectMake(270, 380, 300, 200);
DownloadingcancelButton.frame=CGRectMake(70, 115, 150, 45);
}
else
{
progressAlert.frame = CGRectMake(270, 380, 300, 200);
DownloadingcancelButton.frame=CGRectMake(70, 115, 150, 45);
}
単純なオリエンテーションの問題ですが、私は過去1日間ここで攻撃しました。親切にこれから私を助けてください。前もって感謝します。