#import "MasterViewController.h"
#import "DetailViewController.h"
@interface MasterViewController ()
@end
@implementation MasterViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = NSLocalizedString(@"Master", @"Master");
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
self.clearsSelectionOnViewWillAppear = NO;
self.contentSizeForViewInPopover = CGSizeMake(320.0, 600.0);
}
}
return self;
}
- (void)dealloc
{
[_detailViewController release];
[super dealloc];
}
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table View
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 5;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 100.0;
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CustomCell";
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier: CellIdentifier];
if (cell == nil)
{
cell = [[[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.cellDate.text=@"date";
cell.cellDescription.text =@"Description";
cell.cellImageview.image = [UIImage imageNamed:@"facebook.png"];
cell.cellTitle.text = @"Title";
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
if (!self.detailViewController) {
self.detailViewController = [[[DetailViewController alloc] initWithNibName:@"DetailViewController_iPhone" bundle:nil] autorelease];
}
[self.navigationController pushViewController:self.detailViewController animated:YES];
}
else
{
}
}
@end
.h ファイル
#import <UIKit/UIKit.h>
#import "CustomCell.h"
#import "XMLStringFile.h"
@class DetailViewController;
@interface MasterViewController : UITableViewController{
}
@property (strong, nonatomic) DetailViewController *detailViewController;
@property(strong,nonatomic)CustomCell *customCell;
@end
CustomCell.h
#import <UIKit/UIKit.h>
@interface CustomCell : UITableViewCell{
IBOutlet UIImageView *cellImageview;
IBOutlet UILabel *cellTitle;
IBOutlet UILabel *cellDescription;
IBOutlet UILabel *cellDate;
}
@property (retain, nonatomic) IBOutlet UIImageView *cellImageview;
@property (retain, nonatomic) IBOutlet UILabel *cellTitle;
@property (retain, nonatomic) IBOutlet UILabel *cellDescription;
@property (retain, nonatomic) IBOutlet UILabel *cellDate;
@end
CustomCell.m
#import "CustomCell.h"
@implementation CustomCell
@synthesize cellDate;
@synthesize cellDescription;
@synthesize cellImageview;
@synthesize cellTitle;
- (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
}
- (void)dealloc {
[super dealloc];
}
@end
これは私の両方のクラスです。問題は、カスタムセルのテーブルビューデータにあります白い画面に表示できません。ここで、masterdetails ビュー テンプレートを使用して ios で作業します。ここでは、コンパイル ソース Customcell.xib に m ファイルも追加しました。サイズは 300X100 です。
問題を解決するのを手伝ってください