1
Я видел много других вопросов, подобных этому, но я не нашел (правильный) ответ. У меня есть два UITableView
с на двух разных UIViewController
. Но второй UITableView
не показывает строк.UITableView на втором UIViewController
Код для второй 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
'NSLog'' self.tweetsArray count' в 'numberOfRowsInSection'. Посмотрите, есть ли контент в вашем массиве или нет? –
попытайтесь установить точку останова внутри вашей ячейкиForRowAtIndexPath. – null
Функция не будет выполнять O.o. Я добавил точку останова, но это не останавливается. – user2531284