我有一个名为HomeViewController的视图,我将其嵌入导航视图控制器中。在视图中,我拖动了一个表视图并使用IBOutlet链接它。我从APParallaxHeader库中添加了必要的代码,并使用cocoapods将其导入到我的项目中。
但是我目前在显示图像方面遇到了问题。即使创建了空间,实际图像也不会显示。任何帮助将不胜感激!
这就是我的.h / .m文件的样子:
·H
#import <UIKit/UIKit.h>
#import "UIScrollView+APParallaxHeader.h"
@interface HomeViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
NSArray *menu;
IBOutlet UITableView *menuTableView;
}
@property (nonatomic, strong) IBOutlet UITableView *menuTableView;
@end
的.m
#import "HomeViewController.h"
@interface HomeViewController ()
@end
@implementation HomeViewController
@synthesize menuTableView;
- (void)viewDidLoad
{
[super viewDidLoad];
menu = [NSArray arrayWithObjects: @"1", @"2,", @"3", @"4", @"5", @"6", nil];
[self.menuTableView addParallaxWithImage:[UIImage imageNamed:@"ParallaxImage.jpg"] andHeight:160];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [menu count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"MenuCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.text = [menu objectAtIndex:indexPath.row];
return cell;
}
答案 0 :(得分:1)
找出问题所在。希望将来能帮助其他人。
原来我的tableview存储在我的主视图控制器中的另一个视图中。通过删除该视图并进行以下更改,我能够使其正常工作: