iphone如何将文本字段值传递到tableview?

iphone如何将文本字段值传递到tableview?,iphone,uitextfield,Iphone,Uitextfield,我想让用户在文本字段中填写数字,然后我需要将用户值传递到表视图cell.detailTextLabel?有人知道怎么做吗 我的代码在这里 在.h我有 IBOutlet UITextField *numText; NSString *string; 然后在下午三点 单击按钮时,我可以看到字符串处的值 - (IBAction) scheduleAlarm:(id) sender { [eventText resignFirstResponder]; [numText resignF

我想让用户在文本字段中填写数字,然后我需要将用户值传递到表视图cell.detailTextLabel?有人知道怎么做吗

我的代码在这里

在.h我有

IBOutlet UITextField *numText;
NSString *string;
然后在下午三点

单击按钮时,我可以看到字符串处的值

- (IBAction) scheduleAlarm:(id) sender {
    [eventText resignFirstResponder];
    [numText resignFirstResponder];
    NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar];

    // Get the current date
    NSDate *pickerDate = [self.datePicker date];

    // Break the date up into components
    NSDateComponents *dateComponents = [calendar components:( NSYearCalendarUnit | NSMonthCalendarUnit |  NSDayCalendarUnit ) 
                                                   fromDate:pickerDate];
    NSDateComponents *timeComponents = [calendar components:( NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit ) 
                                                   fromDate:pickerDate];

    // Set up the fire time
    NSDateComponents *dateComps = [[NSDateComponents alloc] init];
    [dateComps setDay:[dateComponents day]];
    [dateComps setMonth:[dateComponents month]];
    [dateComps setYear:[dateComponents year]];
    [dateComps setHour:[timeComponents hour]];
    // Notification will fire in one minute
    [dateComps setMinute:[timeComponents minute]];
    //[dateComps setSecond:[timeComponents second]];
    NSDate *itemDate = [calendar dateFromComponents:dateComps];
    [dateComps release];

    UILocalNotification *localNotif = [[UILocalNotification alloc] init];
    if (localNotif == nil)
        return;
    localNotif.fireDate = itemDate;
    localNotif.timeZone = [NSTimeZone defaultTimeZone];

    //string =  [numText.text retain];
    // string = [[NSString alloc] initWithString:numText.text];
    string = numText.text;

    test = [[NSMutableArray alloc] init];
    [test addObject:string];

//  self.num = array;
    //[num release];




    NSLog(@"%@",string);
    // Notification details
    localNotif.alertBody = [eventText text];

    // Set the action button
    localNotif.alertAction = @"Send SMS";

    localNotif.soundName = UILocalNotificationDefaultSoundName;
    localNotif.applicationIconBadgeNumber = 1;

    // Specify custom data for the notification
    NSDictionary *infoDict = [NSDictionary dictionaryWithObject:@"someValue" forKey:@"someKey"];
    localNotif.userInfo = infoDict;

    // Schedule the notification
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
    [localNotif release];
    //[numText release];
    //[test release];
    [self.tableview reloadData];

}
当我转到UITableView时,我不能将任何值传递到此处。all为null,我使用UITableController第一个选项卡为用户提供了填写编号和事件。然后在第二个选项卡上,我需要向tableview显示用户填写值

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
    }
   // if (cell == nil) {
    //  cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
    //} 
    // Configure the cell...

    notificationArray = [[UIApplication sharedApplication] scheduledLocalNotifications];
    UILocalNotification *notif = [notificationArray objectAtIndex:indexPath.row];
   //  NSString *enNote = [[NSString alloc] initWithString:string];
   NSString *nomber = [test objectAtIndex:indexPath.row];
    NSLog(@"nomber in get test %@",nomber);


    [cell.textLabel setText:notif.alertBody];

    NSString *abc = [NSString stringWithFormat:@"%@ \n %@",[notif.fireDate description], numText.text];
    NSLog(@"%@",nomber);
    [cell.detailTextLabel  setText:abc];
    cell.detailTextLabel.numberOfLines = 2;

    //cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap;




    return cell;
}

创建一个nsmutablearray,并将从textfield获得的值添加到该数组和方法中

(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
cell.textlabel.text = [yourarray objectatindex:index];
}
按你的按钮,点击呼叫

[yourtable reloaddata];

你能给我一些代码吗?你从文本字段哪里得到文本?嗨,我编辑了ady。请帮我看看。你在不同的视图控制器中有文本字段和表视图,对吗?是的。我有两个视图控制器。但是两个i oso只使用一个类。两个i oso使用FirstView。h和FirstView.myou在不同的选项卡中使用了相同的类?