gpt4 book ai didi

iphone - UIImageView 未显示在 UITableView header 中

转载 作者:行者123 更新时间:2023-12-03 19:08:54 26 4
gpt4 key购买 nike

我的问题是我似乎无法从我的包中获取图像以正确显示。该方法位于控制 TableView 的 View Controller 中。 headerView 随 .nib 文件中的 tableview 一起加载,并包含一些可以正常加载的 UILabel(未显示)。有什么想法吗?

- (void)viewDidLoad {
[super viewDidLoad];

[[self view] setTableHeaderView:headerView];
NSBundle *bundle = [NSBundle mainBundle];
NSString *imagePath = [bundle pathForResource:@"awesome_lolcat" ofType:@"jpeg"];
UIImage *image = [UIImage imageWithContentsOfFile:imagePath];
imageView = [[UIImageView alloc] initWithImage:image];
}

最佳答案

如果您已经创建了一个 socket 并将其连接到 Interface Builder 中的 View ,则应该使用该 View ,而不是动态创建 UIImageView。


//this assumes that headerView is an already created UIView, perhaps an IBOutlet
//also, imageViewOutlet is an IB outlet hooked up to a UIImageView, and added as
//a subview of headerView.

//you can also set the image directly from within IB
imageViewOutlet.image = [UIImage imageNamed: @"awesome_lolcat.jpeg"];
[[self view] setTableHeaderView: headerView];

关于iphone - UIImageView 未显示在 UITableView header 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/207022/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com