-1

TableView検索バーを備えた SQLite データベースに接続されたアプリケーションを開発しましたが、すべて正常に動作します。
クリックされた行に関する情報を表示する詳細ビュー コントローラーがあります。AuthorVC.m変数を からに渡すにはどうすればよいDetails.mですか?

部分コード:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{   
    NSLog(@"prepareForSegue: %@", segue.identifier);  
    if ([segue.identifier isEqualToString:@"Details"]) 
        // segue.identifier value here   
    {      
        Details *dv = segue.destinationViewController;
        dv.labelText.text = author.title;
        //  author.title = dv.labelText.text ;
        // your value to pass     

        [segue.destinationViewController setLabelText:author.title];     
    }  
}
4

3 に答える 3

1

これを行う:

Create property of variable in myDetails to pass data
Suppose i have NSString *strAuthoTitle in myDetails

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 
 //Depending upon cell index pass your data differently
 myDetails *objmyDetails = [myDetails alloc] initWithNib:@"myDetails" bundle:nil] //alloc your controller for navigation 

 objmyDetails.strAuthoTitle = [yourArrayofAuthorTile objectAtIndex:indexPath.row];

 //Simarly other data can be passed
}

ストーリーボードを使用しているとは言及していないので、AuthorVC と Details コントローラーの間にセグエを作成し、そのセグエを使用する必要があります。

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
 {   
  //NSLog(@"prepareForSegue: %@", segue.identifier);      
  if ([segue.identifier isEqualToString:@"DetailsPass"]) // segue.identifier value here
  {
   objmyDetails = segue.destinationViewController;
   objmyDetails.strText =lblText.text; // your value to pass
   //[segue.destinationViewController setStrText:lblText.text];
  }   
 }
于 2012-07-20T08:55:59.823 に答える
0

detailedVC に 2 つのプロパティがstrNameあり、strDescription...

detailedVC をスタックにプッシュする前よりも、次のような簡単な操作を行うことができます。

detailedVCObject.strName = @"whatever";
detailedVCObject.strDescription = @"whatever";

それが役立つことを願っています...

于 2012-07-20T08:58:19.363 に答える
0

ストーリーボード付き

seque ios5ストーリーボードuitableviewのデータを詳細ビューに渡す方法

http://kurrytran.blogspot.in/2011/10/ios-5-storyboard-and.html


ストーリー ボードがない場合、クラス 1 の変数にアクセスする必要があります。たとえば、以下の例を参照してください。たとえば、テーブルの行をクリックすると、ルート ビューなどの別のビューに移動する必要があります。したがって、このためにルートビューで変数を定義し、テーブルの didselect メソッドでオブジェクトを作成するときにこのビューにアクセスします。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

RootViewController *rvController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:[NSBundle mainBundle]];

//Increment the Current View
rvController.CurrentLevel += 1;

//Set the title;
rvController.CurrentTitle = [dictionary objectForKey:@"Title"];

//Push the new table view on the stack
[self.navigationController pushViewController:rvController animated:YES];

[rv release]
}
于 2012-07-20T08:53:29.720 に答える