в моем приложении я использую раскадровки. В раскадровке я использовал контроллер представления по умолчанию для входа и создал другое имя контроллера имен Inventory. В новом контроллере представления я использую представление таблицы. Отображается таблица, но методы делегата и источника данных не вызываются. Я пробовал много решений, но я впадина понять код problem.The я использовал это:методы представления делегатов в виде таблиц не отображаются в новом представлении контроллера в раскадровках
#import <UIKit/UIKit.h>
@interface InventoryViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
@end
файл реализация:
#import "InventoryViewController.h"
#import "customCell.h"
@interface InventoryViewController()
@end
@implementation InventoryViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = [UIColor blueColor];
UITableView *table = [[UITableView alloc] initWithFrame:CGRectMake(0, 110, 320, 350)];
table.delegate = self;
table.dataSource = self;
[self.view addSubview:table];
[table relaodData];
}
- (IBAction)Logout:(id)sender {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"Login"];
[self.navigationController pushViewController:vc animated:YES];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - UITableViewDelegate Methods
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1; }
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSLog(@"hello");
return 5;
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
customCell *cell = [tableView dequeueReusableCellWithIdentifier:@"customcell"];
if (cell == nil)
{
cell = [[customCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:@"customcell"];
}
// Here we use the provided setImageWithURL: method to load the web image
// Ensure you use a placeholder image otherwise cells will be initialized with no image
cell.item_image.image = [UIImage imageNamed:@"ipad_strip_logo.png"];
cell.type.text = @"electronics";
cell.name.text = [NSString stringWithFormat:@"my object %d",indexPath.row];
return cell;
}
@end
является «привет», напечатанным в журнале при запуске проект? – Ashutosh
@Ashu no hello не печатается, а клетки no.of также не являются 10 .. – BalaChandra