开发者

connect UITableView + UITableView

Right now I have an indexed UITableView that goes to a detail view but i want it to go to another UITableView then a detail view.

my code like this:

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

displyAnnController *anController = [[displyAnnController alloc] initWithNibName:@"AnnView" bundle:[NSBundle mainBundle]];

DetailViewController *dvController = [[DetailViewController alloc] initWithStyle:UITableViewStyleGrouped];

switch (indexPath.row) {
    case 0:
        [self.navigationController pushViewController:anController animated:YES];
        [anController release];
        anController = nil;
        break;
    case 1:
        [self.navigationController pushViewController:dvController animated:YES];
        [dvController release];
        dvController = nil;
        break;
    default:
        break;
}`

and when I press the cell with index 0 in the simulator, the program is crash!

what's the problem? pleas help me ..


No, I didn't override the -initWithNibName, I just use it as the same way here,but to push to ControlView NOT TableView.Also,no errors in debug console. and I have tried to release the controllers after the switch block, but the program still crash :( anyway, it's work when I write:

displyAnnController *anController = [[displyAnnController alloc] initWithStyle:UITableViewStyleGrouped]];

instead of :

displyAnnController *anController = [[displyAnnController alloc] initWithNibName:@"AnnView" bundle:[NSBundle mainBundle]]

Temporarily, I accept this just to complete my work! but I hope to find any help example bec开发者_Go百科ause no need to be as group.

thanks all for help and recommendations.


View the debug console (Cmd-Shift-R) and see what the error is.

Are you overriding the -initWithNibName message on displyAnnController? Or the -viewDidLoad message?

You also have a memory leak. You always +alloc both controllers, but only -release one of them. Don't +alloc your controller unless you are going to actually use it.


I think your application is crashing because first you have released the view and then you are making it nil.If it is released once then it is not getting the reference to make it nil.Try it once.It may work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜