Я создаю приложение в Xcode с использованием табличных представлений. Я добавил новую активность tableview и добавил код.Tableview не заполняется xcode
У меня также есть источник данных владельца и владелец владельца для просмотра таблиц. Он получает список, который у него есть список прямо перед кодом, чтобы добавить его в таблицу, так как мой журнал показывает все элементы.
Я не вижу, чего у меня нет.
<code>
#import <UIKit/UIKit.h>
@interface BlogViewController : UITableViewController
{
NSMutableArray *blogList;
}
@end
#import "BlogViewController.h"
#import "BlogController.h"
@implementation BlogViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self.navigationController.navigationBar setTintColor: [[UIColor alloc] initWithRed:0.25 green:0.0 blue:0.0 alpha:1.0]];
BlogController *blogs = [BlogController sharedManager];
blogList = [blogs.testList mutableCopy];
[self setTitle:@"Blogs"];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
#warning Potentially incomplete method implementation.
// Return the number of sections.
return 0;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
#warning Incomplete method implementation.
// Return the number of rows in the section.
return blogList.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
// Configure the cell...
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
}
NSLog(@"%@", [blogList objectAtIndex:indexPath.row]);
cell.textLabel.text = [blogList objectAtIndex:indexPath.row];
cell.textLabel.font = [UIFont fontWithName:@"Arial" size:17];
cell.textLabel.numberOfLines=0;
cell.textLabel.lineBreakMode = NSLineBreakByCharWrapping;
return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *item = [blogList objectAtIndex:indexPath.row];
CGSize size = [item sizeWithFont:[UIFont fontWithName:@"Arial" size:17]
constrainedToSize:CGSizeMake(220,CGFLOAT_MAX)];
return size.height + 15;
}
-(NSMutableArray *) testList
{
NSMutableArray *testList = [[NSMutableArray alloc] init];
[testList addObject: @"Key Blogs you should familiarize yourself with and potentially seek the attention of"];
[testList addObject: @"Rapradar.com"];
[testList addObject: @"Inflexwetrust.com"];
[testList addObject: @"Globalgrind.com"];
[testList addObject: @"2dopeboyz.com"];
[testList addObject: @"Rap-up.com"];
[testList addObject: @"Youheardthatnew.com"];
[testList addObject: @"Hotnewhiphop.com"];
[testList addObject: @"Rapgenius.com"];
[testList addObject: @"Hiphopwired.com"];
[testList addObject: @"Vladtv.com"];
[testList addObject: @"Worldstarhiphop.com"];
[testList addObject: @"Djbooth.net"];
[testList addObject: @"Sohh.com"];
[testList addObject: @"Hiphopdx.com"];
[testList addObject: @"Allhiphop.com"];
[testList addObject: @"Nahright.com"];
[testList addObject: @"Pitchfork.com"];
[testList addObject: @"Fader.com"];
[testList addObject: @"Complex.com"];
[testList addObject: @"Realtalkny.uproxx.com"];
return testList;
}
</code
беглого взгляда, но это стена» o'code – Coffee
Вы отлаживали код, чтобы увидеть количество элементов в таблице? Вы уверены, что номер раздела равен 0? Попробуйте поставить 1 – Lorenzo