如何使用故事板在表视图中添加子视图 [英] how To add subview in table view using story board
本文介绍了如何使用故事板在表视图中添加子视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用故事板。我想在表视图上选择元素时添加子视图。
I am using story board. I want to add a subview when a element is selected on table view.
- (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;
}
推荐答案
故事板非常有用app flow.Hence添加视图没有任何意义,没有在故事板中显示流程。
Storyboards are useful to show your app flow.Hence there is no point in adding a view without showing the flow in story board.
storyboard segues(视图与另一个视图之间的连接)有三种类型,push,modal和custom。如果您不想进行推送或作为模态存在,您可以通过覆盖 UIStoryboardSegue
的执行方法来创建自己的自定义segue。
storyboard segues(connection between on view to another) are three types,push,modal and custom. If you don't want to do a push or present as a modal, you can create your own custom segue by over riding the perform method of UIStoryboardSegue
.
- (void)perform
{
// Add your own code here.
[[self sourceViewController] addChildViewController:[self destinationViewController]];
}
这篇关于如何使用故事板在表视图中添加子视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文