私はグーグルで、ここでstackoverflowを検索しましたが、解決策を見つけることができませんでした。私が起こることを期待何なぜ私のUITableViewディスプレイは表示されませんか?
: "こんにちは"
を含むのUITableViewを表示するには、ショーの細胞何が起こる:のUITableViewはさえ
viewViewController.h
#import <UIKit/UIKit.h>
@interface viewViewController : UIViewController
@property (strong, nonatomic) IBOutlet UITableView *tableView;
//note: the above property is connected to my UITableViewController
@end
は表示されません。
viewViewController.m
#import "viewViewController.h"
@interface viewViewController()
@end
@implementation viewViewController
@synthesize tableView = _tableView;
- (UITableView *)tableView
{
if (!_tableView){
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
}
return _tableView;
}
- (void)viewDidLoad
{
[super viewDidLoad];
//_tableView = [[UITableView alloc] init];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
//[self setTableView:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
//warning Potentially incomplete method implementation.
// Return the number of sections.
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSLog(@"asking for rows");
//#warning Incomplete method implementation.
// Return the number of rows in the section.
switch (section)
{
case 0:
return 5;
case 1:
return 10;
break;
default:
return 0;
break;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
cell.textLabel.text = @"hi";
return cell;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return @"testtext";
}
@end
私が間違ったことを教えてください、私のコードを修正してください。
FileOwnerはどういう意味ですか?申し訳ありませんが、私はこれでちょっと新しいです。 – blake305
また、私がストーリーボードを利用している場合は、ストーリーボードを使用しています。 – blake305
@ blake305彼はプロトコルメソッド、つまりあなたのケースではviewViewControllerであるデリゲートを実装しようとする人を意味します。 ViewViewControllerの 'viewDidLoad'にStoryboardを使ってデリゲートを接続できない場合は、ヘッダーにプロトコルを含めると仮定して、' _tableView.delegate = self'と '_tableView.dataSource = self'を実行してください:' @interface viewViewController:UIViewController ' –
Jeremy