1

どのテーブルビューセルが選択されたかを知るにはどうすればよいですか? (詳細ビューにいる) 問題はそれです。テーブルビューコントローラーがあります。ここでは、インターネット エントリからテーブルに解析されます。つまり、インターネットからロードされる動的なタブ ビューです。テーブルにいくつのエントリがあるかわからないので、行をクリックしたときにどの詳細ビューを呼び出すかわかりません。だから私は一つの見方をしました。このビューにはカレンダーが含まれています。このカレンダー (これは詳細ビューです) で、選択した行に応じてインターネットからデータを解析します。例: テーブルがあります: エントリ 1、エントリ 2、エントリ 3、エントリ 4 エントリ 2 をクリックすると、引数エントリ 2 で php を呼び出す必要があります。私が解析する正しいxml。

ここに私のテーブルビューのdidSelectRow関数があります:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // Navigation logic -- create and push a new view controller

 if(bdvController == nil)
    bdvController = [[BookDetailViewController alloc] initWithNibName:@"BookDetailView" bundle:[NSBundle mainBundle]];
  Villa *aVilla = [appDelegate.villas objectAtIndex:indexPath.row];

  [self.navigationController pushViewController:bdvController animated:YES]

そして、これがdetailviewcontrollerのセルフビュー機能です:

-(void)loadView {

    [super loadView];

    self.title=@"Month"

    UIBarButtonItem *addButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"ListView" style:UIBarButtonItemStyleDone target:self action:@selector(add:)];
    self.navigationItem.rightBarButtonItem = addButtonItem;

    calendarView = [[[KLCalendarView alloc] initWithFrame:CGRectMake(0.0f, 0.0f,  320.0f, 373.0f) delegate:self] autorelease];
    appDelegate1 = (XMLAppDelegate *)[[UIApplication sharedApplication] delegate];

    myTableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 260, 320, 160)style:UITableViewStylePlain];
    myTableView.dataSource=self;
    myTableView.delegate=self;
    UIView *myHeaderView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, myTableView.frame.size.width,2)];
    myHeaderView.backgroundColor=[UIColor grayColor];
    [myTableView setTableHeaderView:myHeaderView];

    [self.view addSubview:myTableView];
    [self.view addSubview:calendarView];
    [self.view bringSubviewToFront:myTableView];
}

ここで自己ロードでは、if プロシージャを作成する必要があると思います.. if indexPath.row=x parse fisier.php?variabila=title_of_rowx ですが、問題は indexPath 変数をどのように知るかです。

4

1 に答える 1

0

BookDetailViewController でプロパティを設定できます。

BookDetailViewController.h:

@interface BookDetailViewController : UITableViewController {
    NSIndexPath *selectedIndexPath;
}
@property (nonatomic, retain) NSIndexPath *selectedIndexPath;
@end

BookDetailViewController.m

@implementation BookDetailViewController
@synthesize selectedIndexPath;
- (void)dealloc {
    [selectedIndexPath release];
}
// ...
@end

tableView:didSelectRowAtIndexPath

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // Navigation logic -- create and push a new view controller

    if(bdvController == nil) {
        bdvController = [[BookDetailViewController alloc] initWithNibName:@"BookDetailView" bundle:[NSBundle mainBundle]];
    }
    bdvController.selectedIndexPath = indexPath
    Villa *aVilla = [appDelegate.villas objectAtIndex:indexPath.row];

    [self.navigationController pushViewController:bdvController animated:YES]
}

アプリケーションで行っていることによっては、プロパティを NSIndexPath ではなく Villa オブジェクトにする方が理にかなっている場合があります。

于 2010-05-20T14:34:25.257 に答える