如何在iPhone中的didSelectRowAtIndexPath上进行secondView委托

时间:2011-12-20 09:08:06

标签: iphone ios

我在secondView中创建了一个委托,因为从第二个视图我必须传递在textfield中输入的值,此值应该传递给单元格上的firstview。但我的第二个查看字符串没有firstView didSelectRowAtIndexPath:这是我的错误?

firstView.m

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{
    secondview *secondVC = [[secondview alloc] init];
    secondVC.editText = indexPath.row;//i get error why but i create string variable editText on secondview
    secondVC.delegate = self;
    [self.navigationController pushViewController:[secondVC autorelease] animated:YES];
}

#pragma mark - SecondViewControllerDelegate methods

- (void)updateString:(NSString *)aString {
    self.displaytext = aString;
}

secondView.m

- (void)viewWillDisappear:(BOOL)animated 
{
    [super viewWillDisappear:animated];
    if (![self.delegate respondsToSelector:@selector(updateString:)]) {
        return;
    }
    [self.view endEditing:YES];
    [self.delegate updateString:entryfield.text];
}

0 个答案:

没有答案