我正在使用故事板。我想在表视图中选择元素时添加子视图。
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [arr count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
NSString *cellvalue = [arr objectAtIndex:indexPath.row];
cell.textLabel.text=cellvalue;
cell.imageView.image=[UIImage imageNamed:@"1.png"];
return cell;
}
答案 0 :(得分:1)
故事板对于显示您的应用流程非常有用。因此,添加视图没有显示故事板中的流程是没有意义的。
故事板segues(视图与另一个视图之间的连接)有三种类型,push,modal和custom。如果您不想作为模态进行推送或呈现,则可以通过覆盖UIStoryboardSegue
的执行方法来创建自己的自定义segue。
- (void)perform
{
// Add your own code here.
[[self sourceViewController] addChildViewController:[self destinationViewController]];
}
答案 1 :(得分:0)
如果您想直接从StoryBoard直接进行操作,则需要从表格视图单元格(原型单元格)按住Ctrl键拖动到目标视图。