如何在视图中显示数组的内容?
在HomeViewController.m中
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
NSIndexPath *indexPath = self.tableView.indexPathForSelectedRow;
Show *show = [self.shows objectAtIndex:indexPath.section];
ShowContentItem *showItem = show.showContentItems[indexPath.row];
if( [segue.identifier isEqualToString: @"Headline_Section"] ) {
HeadlinesViewController *headlinesVC = (HeadlinesViewController *)segue.destinationViewController;
headlinesVC.shows = [[NSMutableArray alloc] initWithObjects:show, nil];
} else {
NSInteger contentIndex = [self.storyPostContent indexOfObject:showItem];
NSRange rangeForView = NSMakeRange(contentIndex, [self.storyPostContent count] - contentIndex );
ShowContentViewController *showContentVC = (ShowContentViewController *)segue.destinationViewController;
showContentVC.contentList = [self.storyPostContent subarrayWithRange: rangeForView];
}
}
我想在ShowContentViewController
中显示showContentVC.contentList答案 0 :(得分:2)
在ShowContentViewController
中,可能在viewDidLoad
中,创建一个循环遍历contentList
数组的循环。
对于数组中的每个项目,创建一个标签。设置frame
和[self.view addSubview:...];
。增加框架y
位置的变量,使下一个标签低于当前标签。在标签上设置一些文字。