2013-08-05 39 views
1

我看到了很多其他类似的问题,但我没有找到(正确的)答案。我在两个不同的UIViewController s上有两个UITableView s。但第二个UITableView不显示任何行。第二个UIViewController上的UITableView

守则第二的UIViewController(detail.m):

// detail.m  

#import "detail.h" 

@interface detail() 

@end 

@implementation detail { 
} 

@synthesize tweetsArray; 
@synthesize tableView; 
@synthesize searchBar; 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    //1 
    self.tableView.dataSource = self; 
    //2 
    self.tweetsArray = [[NSArray alloc] initWithObjects: 
         @"Always put your fears behind you and your dreams in front of you.", 
         @"A relationship with no trust is like a cell phone with no service, all you can do is play games.", 
         @"People should stop talking about their problem and start thinking about the solution.", 
         @"Dear Chuck Norris, Screw you. I can grill burgers under water. Sincerely, Spongebob Squarepants.", 
         @"My arms will always be open for you, they will never close, not unless you're in them.", 
         nil]; 
} 

//3</pre> 
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    return [self.tweetsArray count]; 
} 

//4 
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    //5 
    static NSString *cellIdentifier = @"SettingsCell2"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 

    //5.1 you do not need this if you have set SettingsCell as identifier in the storyboard (else you can remove the comments on this code) 
    //if (cell == nil) 
    // { 
    //  cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier]; 
    // } 

    //6 
    NSString *tweet = [self.tweetsArray objectAtIndex:indexPath.row]; 
    //7 
    [cell.textLabel setText:tweet]; 
    [cell.detailTextLabel setText:@"via Codigator"]; 
    return cell; 
} 

- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
}  

@end 
+0

'numberOfRowsInSection'中的'NSLog''self.tweetsArray count'。看看阵列中是否有内容? –

+0

尝试在你的cellForRowAtIndexPath中放置一个断点。 – null

+0

该功能不会执行O.o.我已经添加了一个断点,但并没有停止。 – user2531284

回答

0

我没有看到你设置委托的实现代码如下。您需要设置

self.tableView.delegate = self; 
相关问题