Iphone 按用户编辑Uitableviewcell内容
我想在以下方面得到你的帮助 我有一个uitableview列表,其中包含从DB获取的内容。 现在我想编辑tableviewcell内容本身 我的意思是如何允许uitableviewcells可编辑 请让我知道实现上述内容的工作示例链接/参考教程 谢谢你抽出时间Iphone 按用户编辑Uitableviewcell内容,iphone,ios,uitableview,Iphone,Ios,Uitableview,我想在以下方面得到你的帮助 我有一个uitableview列表,其中包含从DB获取的内容。 现在我想编辑tableviewcell内容本身 我的意思是如何允许uitableviewcells可编辑 请让我知道实现上述内容的工作示例链接/参考教程 谢谢你抽出时间 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NS
- (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];
}
NSDictionary *aDict = [self.mySimpleTemplatesArr objectAtIndex:indexPath.row];
NSString *value = [aDict objectForKey:@"value"];
cell.textLabel.text = value;
// Configure the cell...
return cell;
}
这是一个示例,它是我的代码之一:-
@interface CustomizedCellProductDetails : UITableViewCell {
UILabel *sNO;
UILabel *abcWine;
UILabel *redWine;
UILabel *two;
UILabel *hundred;
UILabel *fourTwo;
UILabel *twoOne;
UIImageView *imgView;
UILabel *itemNo;
UILabel *itemName;
UILabel *itemDesc;
UILabel *department;
UILabel *qtyAvailable;
UIButton *check;
}
@property (nonatomic , retain) UILabel *sNO;
@property (nonatomic , retain) UILabel *abcWine;
@property (nonatomic , retain) UILabel *redWine;
@property (nonatomic , retain) UILabel *two;
@property (nonatomic , retain) UILabel *hundred;
@property (nonatomic , retain) UILabel *fourTwo;
@property (nonatomic , retain) UILabel *twoOne;
@property (nonatomic , retain) UIImageView *imgView;
@property (nonatomic , retain) UILabel *itemNo;
@property (nonatomic , retain) UILabel *itemName;
@property (nonatomic , retain) UILabel *itemDesc;
@property (nonatomic , retain) UILabel *department;
@property (nonatomic , retain) UILabel *qtyAvailable;
@property (nonatomic , retain) UIButton *check;
-(void) clicked;
@end
导入“CustomizedCellProductDetails.h”
只需在cellforRowAtIndexPath中ust该类的实例,并根据需要对其进行修改。要在运行时更改值,请访问属性
您可以通过以下方式在tableview中实现自定义cemm:-
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
CustomizedCellProductDetails *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[CustomizedCellProductDetails alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.sNO.text=@"2255";
cell.abcWine.text=@"ABCWine";
cell.redWine.text=@"REDWine";
cell.two.text=@"2";
cell.hundred.text=@"100";
cell.fourTwo.text=@"42";
cell.twoOne.text=@"21";
[cell.imgView setImage:[UIImage imageNamed:@"wine.png"]];
cell.itemNo.text=@"Item No 2255";
cell.itemName.text=@"Item Name ABCWine";
cell.itemDesc.text=@"Item Description This is the best wine";
cell.qtyAvailable.text=@"Quantity Available 2";
// Configure the cell...
return cell;
}
更改单元格的高度:-
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 300;
}
不要使用300,而是将单元格的框架高度设置为
cell.frame.size.height
当选择单元格项目时,我为创建示例代码,然后显示模型弹出窗口,然后该项目更新,然后按更新,然后该项目更新并显示在表中
我认为它是一种简单易用的应用程序,也可以启动数据库操作
因此,您可以从这里下载示例代码
我希望您能够轻松理解并将该代码实现到您的项目中,从而解决问题
请下载源代码,由我开发的样本代码,你也可以进一步加强这段代码
是否要编辑UITableview的数据?是的,我要编辑uitableviewcell内容的数据编辑db值并重新加载已更新的行,或者只是重新加载TableView我要问的是如何编辑tableviewcell中的内容(如放置uitextfield)etchello,等等,我会像你想的那样创建演示,并将参考链接提供给youthanks,以获得回复,目前我正在做与你所说的相同的事情。编辑时导航到新页面。你能告诉我如何在列表上编辑它而不是进入新页面吗。请让我知道并感谢你需要实现自定义CellxError:感谢回复,我按照你说的做了尝试。这就是我创建实例的方式。CustomizedCellProductDetails*cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];如果(cell==nil){cell=[[CustomizedCellProductDetails alloc]initWithStyle:UITableViewCellStyleDefault重用标识符:CellIdentifier]自动释放];}我会遇到一些问题。请告诉我如何获得此警告:不兼容的Objective-C类型初始化“struct UITableViewCell*”,预期为“struct CustomizedCellProductDetails*”。请让我知道演示….(定制的CellProductDetails*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]。。另外,当点击单元格时,我无法编辑它,光标也没有显示。请让我知道你必须这样做。我已经这样做了
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 300;
}