【发布时间】:2013-05-13 14:59:23
【问题描述】:
我有一些按钮说明:“点击填写...”。当点击它们时,会弹出一个带有选项的表格视图。如何将这些选项链接到按钮,以便“点击填写..”被用户选择的数据/行替换?我不知道从哪里开始,提前谢谢。
【问题讨论】:
标签: ios uitableview uibutton
我有一些按钮说明:“点击填写...”。当点击它们时,会弹出一个带有选项的表格视图。如何将这些选项链接到按钮,以便“点击填写..”被用户选择的数据/行替换?我不知道从哪里开始,提前谢谢。
【问题讨论】:
标签: ios uitableview uibutton
试试这个:
- (void)tableView: (UITableView *)tableView didSelectRowAtIndexPath: (NSIndexPath *)indexPath {
NSUInteger row = [indexPath row];
NSString *newText = [youArray objectAtIndex:row]; //yourArray contains your datas (of type NSString in this example)
//consider your button btn is an inst var
[btn setTitle:newText forState:UIControlStateNormal];
}
【讨论】:
//在viewcontroller.h文件中创建如下属性,点击按钮弹出
@property (strong, nonatomic) UIButton *button;
//点击按钮时调用弹出视图如下
YourTableViewController *tables = [UITableviewController alloc] init];
tables.button = buttonObjectWhoesTextYouWantToChange;
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:tables];
popover.delegate = self;
popover.popoverContentSize=CGSizeMake(280.0, 327.0);
// 现在在tableviewcontroller的didSelectRowAtIndexPath方法中加入这一行
self.button.text = cell.textLabel.text;
【讨论】: