0

ショッキングなことに、この問題はまだ解決されていません (2012 年 9 月 25 日)。この問題について、私の複数の本や他の経験豊富な iOS 開発者を調査しました。pushViewController コードを追加すると修正されると思いましたが、解決しませんでした。誰かがこれについて私を助けることができるなら、私に知らせてください? 誰かがこの問題に対する答えを知っている場合、報奨金は依然としてこの質問を支持します。

アプリ内で accesoryButtonTappedRowWithIndexPath メソッドのコードを作成しようとしていますが、個々の開示ボタンをクリックすると新しい UI ビュー ウィンドウに移動する方法を見つけるのに苦労しています。Beginning IOS 5 Development のような本を何冊か購入しました。テーブルビューのセクションで、それがどのように行われるかの例を見ていますが、私の中ではうまくいかないようです。これは、私が現在持っているコードで、以下にリストされています。開示ボタンが選択されたときに「メッセージ」を表示しようとしているメッセージクラスが機能していることを証明していません。本のコードでアクセスできることがわかりますが、私のコードでは動作しないので、次のビューに移動できます。誰でもこれについて私を助けることができますか? 以下の画面は、テーブルのセルをクリックしたときの他のメソッド アクションが機能し、メッセージ アラートが正常にポップアップすることを示しています。

どうもありがとう。

3位 2位 1位 nbhoodcontroller_push ns_log

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


if (NbhoodDetailController == nil) 
{
    NbhoodDetailController = [[LWWDisclosureDetailController alloc]initWithNibName:@"LWWDisclosureDetail" bundle:nil];

}
NbhoodDetailController.title = @"Getting Neighborhood Details";
NSUInteger row = [indexPath row];
NSString *SelectedNeighborhood = [ListBlocks objectAtIndex:row];
NSString *DetailMessage = [[NSString alloc]
                           initWithFormat:@"You pressed the button for the Neighborhood   %@ to invest in.", SelectedNeighborhood];
NbhoodDetailController.title = SelectedNeighborhood;
NbhoodDetailController.message = DetailMessage;// <-- the "message" class isn't accessible for some reason as well so I can click on the disclosure button and give a message.

以下のインデックス コードの行のセル:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:    (NSIndexPath *)indexPath//returns instances of the UITableViewCell class rows that have to     be populated into the table view.  
{
static NSString *NeighborhoodDBListCellIdentifier = @"NeighborhoodDBListCellIdentifier";

UITableViewCell *cell = [tableView    dequeueReusableCellWithIdentifier:NeighborhoodDBListCellIdentifier];//as table view cells   scroll off the screen, they are placed into a queue of cells available to be reused. So im   using those cells for the new rolls that scroll on the screen to assign them to.

if(cell == nil)//in case of no spare reuseable cells we create new ones here. If   dequeueReusableCellWithIdentifier doesn't have any to spare.
{
    cell = [[UITableViewCell alloc]
            initWithStyle:UITableViewCellStyleDefault 
            reuseIdentifier:NeighborhoodDBListCellIdentifier];
}
//assigning the images for the rows and also the disclosure buttons for each row
UIImage *image = [UIImage imageNamed:@"rowControlsIcon.png"];
cell.imageView.image = image;
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;


NSUInteger row = [indexPath row];
cell.textLabel.text = [ListBlocks objectAtIndex:row];//the output results of what the    cell is goes to the textLabel in the TableViewCell as text.  Like "Armour Neighhborhood"

return cell;


}

正常に切り替わる別の画面でセグエを機能させる方法の例

4

3 に答える 3

0

表示したい新しいコントローラーを作成するだけでは不十分です。accessoryButtonTappedForRowWithIndexPath:また、次のように、メソッドの最後にナビゲーションコントローラーに渡す必要があります。

[self.navigationController pushViewController:NbhoodDetailController
                                     animated:YES];
于 2012-09-06T10:14:38.483 に答える
0

- (id)instantiateViewControllerWithIdentifier:(NSString *)identifier ストーリーボードを使用している場合は、UIStoryboardでViewControllerをインスタンス化する必要があります

例 :

// if your storyboard file name is MainStoryboard_iPhone.storyboard then use @"MainStoryboard_iPhone" as the parameter
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone"
                                                     bundle:[NSBundle bundleForClass:[self class]]];
NbhoodDetailController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"Your view controller identifier"];
// You need to set the view controller identifier in IB

次に、それをナビゲーションスタックにプッシュできます

[self.navigationController pushViewController:viewController animated:YES];

それを行う別の方法は、セグエを使用することです。

于 2012-09-14T14:39:12.053 に答える
0

以前のコメント スレッドから抜け出す...あなたの問題はコントローラーの作成にあると思います。これの代わりに:

NbhoodDetailController = [[LWWDisclosureDetailController alloc]
    initWithNibName:@"LWWDisclosureDetail"
    bundle:nil];

これを行う:

NbhoodDetailController = [[LWWDisclosureDetailController alloc]
    initWithNibName:@"LWWDisclosureDetail"
    bundle:[NSBundle mainBundle]];

これはただの推測です、本当に。一歩進んで、実際に何がうまく作成されているかを確認するのは興味深いことです。

于 2012-09-11T07:55:56.917 に答える