0

令人震惊的是,此问题仍未解决(2012 年 9 月 25 日)。在我的多本书和其他有经验的 iOS 开发人员中研究过这个问题。我原以为添加 pushViewController 代码会修复它,但没有解决。如果有人可以帮助我,请告诉我?如果有人知道这个问题的答案,赏金仍然代表这个问题。

我正在尝试在我的应用程序中为 accesoryButtonTappedRowWithIndexPath 方法构建代码,但是当您单击每个单独的披露按钮时,我无法找到如何进入新的 UI 视图窗口。我买了几本书,比如《开始 IOS 5 开发》。在 Table Views 部分中,我看到了一个如何完成的示例,但我似乎无法将其放入我的。这是我现在列出的代码。The message class where I am trying to display a "message" when the disclosure button is selected to prove that it is working is not pulling up. 我看到它可以在书中的代码中访问,但我无法让它在我的工作中工作,所以我可以让它进入下一个视图。任何人都可以帮助我吗?下面的屏幕显示,当您单击表格的单元格时,我的其他方法操作可以正常弹出消息警报。

非常感谢。

第三 第二 第一 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;


}

我如何让 segue 为我的另一个可以正常切换的屏幕工作的示例

4

3 回答 3

0

仅创建要显示的新控制器是不够的。您还必须在方法结束时将其传递给导航控制器accessoryButtonTappedForRowWithIndexPath:,如下所示:

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

当你使用故事板时,你需要 - (id)instantiateViewControllerWithIdentifier:(NSString *)identifier 在你的 UIStoryboard 上实例化你的视图控制器

例子 :

// 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];

另一种方法是使用segue。

于 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 回答