1

ストーリーボードを使用して UITableViewController を UIView に接続しようとしています。小さな配列を表示する UITableViewController を表示する Navigation Controller に接続する TabBarController があります。行をクリックすると、ラベル付きの単純な UIView がトリガーされ、UINavigationController に引き続き表示されるので、UITableViewController に戻ることができます。

配列を使用して UITableViewController を正常に表示することはできますが、選択したときに行をトリガーすることはできません。

これは私の UITableViewController (AtoZController.m) ファイルです:

#import "AtoZController.h"
#import "StoreDetailsView.h"

@interface AtoZController ()

@end

@implementation AtoZController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.title = NSLocalizedString(@"A to Z", @"An A to Z List of Stores");

    AtoZArray = [[NSMutableArray alloc] init];

    [AtoZArray addObject:@"Apple"];
    [AtoZArray addObject:@"Boots"];
    [AtoZArray addObject:@"Topman"];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
    } else {
        return YES;
    }
}


#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.
    return [AtoZArray count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

    // Configure the cell...

    NSInteger row = [indexPath row];
    cell.textLabel.text = [AtoZArray objectAtIndex:row];
    return cell;
}

UITableViewController から UIView に、storeDetailsS​​egue という名前のセグエが接続されています。次のビューをトリガーするために prepareForSeque メソッドを使用しようとしていますが、次のコードではうまくいきませんでした。

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    NSIndexPath *path = [self.tableView indexPathForSelectedRow];
    StoreDetailsView *detail = [self detailForIndexPath:path];
    [segue.destinationViewController setDetail:detail];
}

「「AtoZController はセレクター 'detailForIndexPath' を宣言します」の @interface が表示されない」というエラーがあると言い続けます。これまでストーリーボードを使用したことがないため、完全に間違ったことをしている可能性があります。私が欲しいのは、選択された行番号を表示するように動的に変化するラベルを単純な UIView に表示することです。

UITableViewController が実際に UITableView であるべきかどうかはわかりませんが、セグエやストーリーボードを使用したことがないため、何が問題を引き起こしているのかわかりません。

どんなアドバイスでも大歓迎です。

アップデート:

そのため、UIViewController を表示することはできましたが、ビューを表示する前にラベルを更新することはできません。

4

0 に答える 0