Моя пользовательская ячейка просмотра выглядит следующим образом http://img34.imageshack.us/i/screenshot20110210at627.png/
@interface AddSiteAddressCell : UITableViewCell {
IBOutlet UITextField *street;
IBOutlet UITextField *city;
IBOutlet UITextField *province;
IBOutlet UITextField *postal;
IBOutlet UITextField *country;
IBOutlet UITextField *siteName;
}
@property (nonatomic,retain)UITextField *siteName;
@end
@implementation AddSiteAddressCell
- (void) textFieldDidEndEditing:(UITextField *)textField {
NSLog(@"%@",street);
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code.
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state.
}
- (void)dealloc {
[super dealloc];
}
@end
AddSiteViewController.m
-
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if(indexPath.section == 0)
{
static NSString *MyIndentifier = @"MyIdentifier";
MyIndentifier = @"tblCellView";
//static NSString *CellIdentifier = @"Cell";
AddSiteAddressCell *cell = (AddSiteAddressCell *)[add_site dequeueReusableCellWithIdentifier:MyIndentifier];
if(cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"AddSiteAddressCell" owner:self options:nil];
cell = nameCell;
}
return cell;
}else if (indexPath.section == 1)
{
static NSString *MyIndentifier = @"MyIdentifier";
MyIndentifier = @"tblCellView";
//static NSString *CellIdentifier = @"Cell";
AddSiteAddressCell *cell = (AddSiteAddressCell *)[add_site dequeueReusableCellWithIdentifier:MyIndentifier];
if(cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"AddSiteAddressCell" owner:self options:nil];
cell = addressCell;
}
return cell;
}
/*static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...*/
return nil;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic may go here. Create and push another view controller.
AddSiteAddressCell *cell = (AddSiteAddressCell *)[add_site cellForRowAtIndexPath:[indexPath row]];
self.test = cell.siteName.text;
NSLog(@"%@",self.test);
}
Мой полный вид выглядит следующим образом:
http://img29.imageshack.us/i/screenshot20110211at940.png/ Так выглядит мой вид.2 раздела с 1 строкой и 1 пользовательской ячейкой
Вот код из моей CustomTableViewCell
Мне интересно, как я могу получить доступ к своему текстовому полю в контроллере таблицы, чтобы сохранить введенные данные