我在tableview单元格中有一个按钮(名为"deleteTemplate"),当按下它时,我应该得到按钮所在单元格的"index.row".任何人都知道如何获取单元格的"index.row" ,当你单击单元格中的按钮?
我目前的按钮代码:
UITableViewCell *clickedCell = (UITableViewCell *)[[sender superview] superview];
NSIndexPath *clickedButtonIndexPath = [self.tableView indexPathForCell:clickedCell];
NSDictionary *dic = [tableData objectAtIndex:clickedButtonIndexPath.row];
Run Code Online (Sandbox Code Playgroud)
但是clickedButtonIndexPath = NULL?:(
这适用于iOS 6.
谢谢!!!
我一直在寻找帮助,但没有运气:(
我想在TableViewCells中设置字幕.每个单元格中的字幕不能相同.我一直在写一些代码:
- (void)viewDidLoad
{
[super viewDidLoad];
tableData = [[NSArray alloc] initWithObjects:@"cell 1", @"cell 2", nil];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [tableData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = nil;
cell = [tableView dequeueReusableCellWithIdentifier:@"MyCell"];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"MyCell"];
}
cell.textLabel.text = [tableData objectAtIndex:indexPath.row];
cell.detailTextLabel.text = @"Subtitle 1", @"Subtitle 2", nil;
return cell;
}
Run Code Online (Sandbox Code Playgroud)
问题在于 cell.detailTextLabel.text = @"Subtitle 1", @"Subtitle 2", nil;
有人知道如何在每个单元格中设置不同的字幕吗?
祝好运!:)
我得到了这个分段控制,但它不能正确显示我的图像:(圆圈需要是绿色,黄色和红色.请参阅截图以了解:D
如果你知道我做错了什么或遗失了请回答:)谢谢!
这适用于iOS 6 ..


ios ×2
ios7 ×2
xcode ×2
cell ×1
objective-c ×1
subtitle ×1
tableview ×1
uitableview ×1
xcode5 ×1