
如何在图像中单击按钮时实现下拉列表?
这使它看起来真的像一个下拉列表。这是我用来创建一个的代码。为此首先导入框架,制作动态视图并添加背景图像。然后在动态视图中添加表格。
-(IBAction)DropDownTable:(id)sender
{
UIView *BackGrView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 200)];
BackGrView.hidden = NO;
if(TableView.frame.origin.y ==203)
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5f];
[TableView setFrame:CGRectMake(224, 204, 27, 160)];
[UIView commitAnimations];
[self.view TableView];
}
else if (TableView.frame.origin.y == 204)
{
[TableView setFrame:CGRectMake(224, 203, 27, 0)];
BackGrView.hidden = YES;
}
[self.view addSubview:TableActivityLevel];
}
我认为下面的链接将有助于实现一些修改。请通过以下链接:
这里UITableView用于显示弹出框。您可以实现一个Section方法TableView来实现您想要的相同效果。
谢谢...
使用自定义视图非常简单。供您参考,我可以向您展示其实现步骤:
单击该按钮时,显示(Sectioned Table View)UITableview如图所示(希望您了解创建UITableView),然后使用cellForRowIndex委托加载您的列表视图内容。在选择表格的行时,您可以获取值并将 UITableView 隐藏在didselectrowatIndexPath委托中。