UpdatesTableViewCell クラスという名前の、プロジェクト全体で使用するカスタム tableviewcell を開発します。私が今までに得たものは、この質問の下部にあるスナップショットに示されています。
残念ながら私が経験した唯一の問題は、アプリのレイアウトが縦向きでのみ機能し、横向きモードでは機能しないことです.
つまり、私の iPhone が横向きに回転すると、上記のカスタム セルは、含まれているテーブル ビューのすべてのスペースを埋めないように見え、その後にギャップが残ります。それは快適なユーザー エクスペリエンスではありません。
また、自動サイズ設定を設定して、tableviewcell を左右両方に拡張し、コンテナのスペースを埋めるように指示していることに注意してください。(1枚目のスナップ写真参照)
横向きで正しく表示するためのアドバイスをいただければ幸いです
..
UpdatesTableViewCell.xib
UpdatesTableViewCell.h
#import <UIKit/UIKit.h>
@interface UpdatesTableViewCell : UITableViewCell
@end
UpdatesTableViewCell.m
#import "UpdatesTableViewCell.h"
@implementation UpdatesTableViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
ここでの最後の部分は、ResultViewController.m (UpdatesTableViewCell が使用される親 UITableViewController) のコードのスニペットです。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UpdatesTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray* views = [[NSBundle mainBundle] loadNibNamed:@"UpdatesTableViewCell" owner:nil options:nil];
for (UIView *view in views) {
if([view isKindOfClass:[UITableViewCell class]])
{
cell = (UpdatesTableViewCell*)view;
}
}
}
return cell;
}
前述の予期しない結果は次のとおりです。