2011-10-27 14 views
0

ハ、誰も私はいくつかの値を含んでいるtabeviewのセルを持っています。ユーザーがセルの1つをタップすると、ボタン付きのサブビューが表示され、popoupにそこにsave.Myという名前のボタンがあります。セルの値で保存ページにリダイレクトし、保存ページのテキストビューに表示します。これは、保存ページにリダイレクトするための私のコードです。テーブルビューのセル値を別のページ(uiviewcontroller)に渡す方法は?

-(IBAction)buttonclick{ 
StatusViewController *detailViewController = [[StatusViewController alloc] initWithNibName:@"StatusViewController" bundle:nil]; 

    detailViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical; 
    [self presentModalViewController:detailViewController animated:YES]; 
    [UIView commitAnimations]; 
    [detailViewController release];} 
+0

この質問にこの質問?いただきました!間違ってdownvoted heyy? – iNips

答えて

3

クラスのNSStringの値にセルの文字列値を格納します。

最後に選択したテーブルビューセルから文字列値を取得する場合。デリゲートメソッドから文字列値を取得する

NSString *localStringValue; 
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    localStringValue = [tableView cellForRowAtIndexPath:indexPath].textLabel.text; 
} 

StatusViewControllerでNSStringプロパティを作成します。

@interface StatusViewController : UIViewController { 

} 
@property(nonatomic, retain) NSString *yourStringProperty; 

、あなたが使用して文字列の値にアクセスすることができ、以下のように

self.yourStringProperty 
+0

さん、stringvaluetobe配置されたメンズですか?しかし、tableviewから値を得ることができますか?もし私が値を持っていれば、私は文字列を渡すことができます。 – iNips

+0

あなたはこれをやるのを手伝ってもらえますか? – iNips

+0

私の答えを更新しました。 – sElanthiraiyan

1
NSUInteger row = [indexPath row]; 
NSString value = [listOfItems objectAtIndex:row]; //use this code 

StatusViewController *detailViewController = [[StatusViewController alloc] initWithNibName:@"StatusViewController" bundle:nil]; 
detailViewController.label=value; 
detailViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical; 
[self presentModalViewController:detailViewController animated:YES]; 
[UIView commitAnimations]; 
[detailViewController release]; 

をStatusViewControllerクラスで

StatusViewController *detailViewController = [[StatusViewController alloc] initWithNibName:@"StatusViewController" bundle:nil]; 

detailViewController.yourStringProperty = localStringValue; 

をあなたのコードを変更StatusViewController.hファイル

NSString *label; 
@property (nonatomic, assign) NSString *label; 

StatusViewController.m

-(void) viewdidload{ 
     NSLog(@"%@",label); 
    } 
関連する問題