我使用数组初始化表中viewDidLoad
的数据,然后将数据添加到单元格.这是我在书中读到的标准方法.这就是我所拥有的:
- (void)viewDidLoad {
[super viewDidLoad];
//Create array and add data ("tableViewValues" is initialized in .h file)
tableViewValues = [[NSMutableArray alloc]init];
[tableViewValues addObject:@"$280,000.00"];
[tableViewValues addObject:@"$279,318.79"];
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
NSString *cellValue = [tableViewValues objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
return cell;
}
Run Code Online (Sandbox Code Playgroud)
因此,当视图加载时,这两个货币值都在我的表中.现在在另一个函数中,我根据用户在文本字段中输入的内容填充另一个具有不同货币编号的数组.如何更新当前的表视图并将这些值替换为其他数组中的值?谁能帮我?谢谢!
我正在使用文本字段委托方法"shouldChangeCharactersInRange",我想知道是否有任何方法可以判断用户是否正在删除字符或键入字符?谁知道?谢谢.
嗨,我一直在关注如何在用户点击工具栏按钮项时显示弹出窗口的书.它工作正常但我想在用户点击textField时显示popover.这似乎是一些微小的调整.就像改变IBAction"showPopover"方法一样.这是该方法的代码:
- (IBAction)showPopover:(id)sender{
if(popoverController == nil){ //make sure popover isn't displayed more than once in the view
popoverController = [[UIPopoverController alloc]initWithContentViewController:popoverDetailContent];
[popoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
popoverController.delegate = self;
}
}
Run Code Online (Sandbox Code Playgroud)
除了"presentPopoverFromBarItem"之外还有另一个实例方法叫做"presentPopoverFromRect".我会用它吗?我试着为它编写代码,但我不确定如何将它与我的TextField相关联或如何绘制需要的矩形.任何人都可以帮我这个吗?谢谢.