Iphone 将图像和文本添加到tableview
我尝试将从文本字段中获取的一些文本和从相册中获取的图像添加到Iphone 将图像和文本添加到tableview,iphone,ios,uitableview,uibutton,uitabbarcontroller,Iphone,Ios,Uitableview,Uibutton,Uitabbarcontroller,我尝试将从文本字段中获取的一些文本和从相册中获取的图像添加到UITableViewCell 在一个UIViewController中,我有一个UITextField和一个UIImageView。这是我用来 填充我将显示在UITableView单元格中的产品数组 Article *article1 = [[Article alloc] initWithTitle: @"First Text" Subtitle: @"Data&Time" Thumbnail: [UIImage imageN
UITableViewCell
在一个UIViewController
中,我有一个UITextField
和一个UIImageView
。这是我用来
填充我将显示在UITableView
单元格中的产品数组
Article *article1 = [[Article alloc] initWithTitle: @"First Text" Subtitle: @"Data&Time" Thumbnail: [UIImage imageNamed: @"image.png"]];
articles = [[NSMutableArray alloc] init];
[articles addObject:article1];
您必须继承UICell类,示例太多了。只需谷歌smth,比如“自定义UITableView”或“自定义UITableViewCell”
另外,Cocoa中还有单元格的左边图像。是否希望单元格显示文章对象的属性?假设您只有一个部分,并且UITableViewController已经有一个对名为“Articles”的文章数组的引用
添加自定义单元格以在表视图中显示图像
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"MoreDetailCell";
MoreDetailCell *cell = (MoreDetailCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"MoreDetailCell" owner:self options:nil];
for (id currentObject in topLevelObjects){
if ([currentObject isKindOfClass:[UITableViewCell class]]){
cell = (MoreDetailCell *)currentObject;
break;
}
}
}
cell.compImage.image = [UIImage imageNamed:@"Placeholder.png"];
cell.yourtexfieldname.text = @"ABC";
}
你能试着重新措辞你的问题吗?不太清楚。自足样本有助于理解问题。先谢谢你。对不起,你想做什么?是否要在UITableView中显示项目数组中包含的项目?你想要一些建议吗?提前谢谢。对不起,有人更改了我的问题。请尝试在您的问题下添加一些上瘾的解释。你可以试着把你的问题分成几个步骤。例如:1)创建文本和图像并将其添加到单元格中2)创建包含表视图的视图控制器3)将该控制器添加到选项卡栏控制器中。希望有帮助。我尝试从文本字段中提取文本,并将图像从imageview(在uiimageview中,我有用户从相机拍摄的图片)中提取到UITableViewCell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"MoreDetailCell";
MoreDetailCell *cell = (MoreDetailCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"MoreDetailCell" owner:self options:nil];
for (id currentObject in topLevelObjects){
if ([currentObject isKindOfClass:[UITableViewCell class]]){
cell = (MoreDetailCell *)currentObject;
break;
}
}
}
cell.compImage.image = [UIImage imageNamed:@"Placeholder.png"];
cell.yourtexfieldname.text = @"ABC";
}