#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
自定义单元格.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
这是我的两个类问题是在customcell 的tableview 数据中无法在白屏上显示。在这里,我使用 masterdetails 视图模板在 ios 中工作。这里我还在编译源中添加了 m 文件 Customcell.xib 大小为 300X100 这里我的输出我的 xib 文件如下
请帮我解决问题