私はフォローを使って欲しいものを作ることができました。これは最善の方法やクリーンな方法ではありませんが、StackOverFlowの誰も良い提案はありませんでした。
最初の3つのUITableViewCellsをサブクラス化し、自分の画像のサイズを考慮してフレームサイズを設定しました。その後
- (void)setFrame:(CGRect)frame {
float cellWidth = (frame.size.width - 345);
frame.size.width = cellWidth;
[super setFrame:frame];
}
私のUITableViewControllerののviewDidLoadで私が作成し、IBOutlet( "firstCell")とテーブルビューの最初の静的セルを使用してUIImageViewを配置。次に、回転をソートし、最後にUIImageViewをビューに追加するautoResizingMaskを設定します。
//Create and position the image view
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake((firstCell.frame.size.width), (firstCell.frame.origin.y + 70), 300, 137)];
// Add border and round corners of image view to make style look a little like tableviewcells
[imageView.layer setBorderColor:[UIColor colorWithWhite:0 alpha:0.5].CGColor];
[imageView.layer setBorderWidth:2.0];
[imageView.layer setCornerRadius:5.0];
[imageView setClipsToBounds:YES];
//Set the image in the image view
UIImage *image = [UIImage imageNamed:@"defaultPicture.png"];
imageView.image = image;
//Set resizing of image view for when view is rotated
imageView.contentMode = UIViewContentModeRedraw;
imageView.autoresizingMask = UIViewContentModeScaleAspectFit;
//Add tap gesture for imageview to initiate taking picture.
imageView.userInteractionEnabled = YES;
UITapGestureRecognizer *imageViewTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(takePicture:)];
[imageView addGestureRecognizer:imageViewTap];
//Add image view to view
[self.view addSubview:imageView];
これは完全にテストされていないと私は偉大な実装ではありません確信しているが、私は後だ効果のための出発点。あなたがより良い方法を知っていれば、返信してください。
注:上記のコードは、iPad上で自分のアプリケーションのために書かれたが、スクリーンショットが、私はiPhone
にやったテストからのものされているが、第二のセクション内の他の行に影響しますので、私はのUITableViewの幅を変更する必要はありません。私は、カスタムセルのアプローチを使用したいが、これを実装する正しい方法を知りたい。 –
@MattPriceので、カスタムセルを実装する方法が必要です。 – vishiphone
@vishiphoneは私の答えを以下に見ています。私は欲しいものをやった。私はそれを10時間の回答としてマークすることはできません –