Iphone 如何在表格视图中制作左、右括号?
我看到一些应用程序在表视图单元格中有Iphone 如何在表格视图中制作左、右括号?,iphone,Iphone,我看到一些应用程序在表视图单元格中有。 如果我按下左括号或右括号,它们之间的某些内容(文本或图形)会发生更改。 在设置菜单中使用。 我怎样才能做到?是否有任何代码?您需要通过子类化UITableViewCell并向单元格视图添加两个按钮来创建自定义的tableview单元格 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { }这取决于
我怎样才能做到?是否有任何代码?您需要通过子类化UITableViewCell并向单元格视图添加两个按钮来创建自定义的tableview单元格
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
}这取决于您的确切视野。网络上有很多这样的例子;我差点就明白了。左括号之前有文本,括号之间有文本或图形。我还是不知道怎么把它放在括号里。我是初学者。它看起来是这样的:文本<图像或文本>当你按照我的代码放置imageview时,在图像之间放置UILabel并编写它。我已经编辑了我的答案。使用它,它将对你有用。并根据您的需要更改位置…如果我想在括号之间显示文本,我将使用UILabel。如果我想在括号之间显示图像,我是否要创建另一个图像视图?对吗?最后一个问题。当我触摸括号时,我是否必须从UIImageView中创建子类来响应?
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
UIImageView *imgView;
UIImageView *imgView1;
UILabel *lblName;
if(cell == nil)
{
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
imgView = [[UIImageView alloc] initWithFrame:(5,0,20,62)];
[imgView setImage:[UIImage imageNamed:@"leftimg.png"]];
imgView.tag = 55;
[cell.contentView addSubview:imgView];
[imgView release];
lblName = [[UILabel alloc] initWithFrame:CGRectMake(30, 0, 100, 25)];
lblName.tag = 77;
[cell.contentView addSubview:lblName];
[lblName release];
imgView1 = [[UIImageView alloc] initWithFrame:(200,0,20,62)];
[imgView1 setImage:[UIImage imageNamed:@"rightimg.png"]];
imgView1.tag = 66;
[cell.contentView addSubview:imgView1];
[imgView1 release];
}
else
{
imgView = (id)[cell.contentView viewWithTag:55];
imgView1 = (id)[cell.contentView viewWithTag:66];
lblName = (id)[cell.contentView viewWithTag:77];
}
lblName.text = @"your text";
return cell;