我有一些按钮说明:“点击填写......”。当点击它们时,会弹出一个带有选项的表格视图。如何将这些选项链接到按钮,以便“点击填写..”被用户选择的数据/行替换?我不知道从哪里开始,在此先感谢。
问问题
971 次
2 回答
0
尝试这个:
- (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];
}
于 2013-05-13T15:08:37.473 回答
0
// 在单击按钮时弹出的 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;
于 2013-05-13T16:03:15.257 回答