小编Mik*_* V.的帖子

Tableview按钮获取index.row

我在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.

谢谢!!!

objective-c uitableview ios ios7

2
推荐指数
1
解决办法
3864
查看次数

Xcode tableview字幕

我一直在寻找帮助,但没有运气:(

我想在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;

有人知道如何在每个单元格中设置不同的字幕吗?

祝好运!:)

xcode cell subtitle tableview

1
推荐指数
1
解决办法
1万
查看次数

iOS 7:Segmentedcontrol不会显示图像颜色

我得到了这个分段控制,但它不能正确显示我的图像:(圆圈需要是绿色,黄色和红色.请参阅截图以了解:D

如果你知道我做错了什么或遗失了请回答:)谢谢!

这适用于iOS 6 ..

选择绿色圆圈的绿色

它只显示蓝色圆圈?

xcode uisegmentedcontrol ios ios7 xcode5

0
推荐指数
1
解决办法
520
查看次数