开发者

How to go from a view to another view controller (iphone)

开发者 https://www.devze.com 2023-03-17 04:53 出处:网络
I have a tab开发者_运维知识库le view in a view controller (view based application), once a user selects one of the cells it should load another view.. I tried the navigation controller thing but that

I have a tab开发者_运维知识库le view in a view controller (view based application), once a user selects one of the cells it should load another view.. I tried the navigation controller thing but that resulted in a huge failure along with 5-6 hours wasted (it crashes when I try to pushViewController onto the nav. controller). Is there anyway to move from one view controller to the other? Keeping in mind I need to send over the selected cell (a string)

Thanks

Edit:For those curious, I created another project as a navigation based application. Everything is working now.

Thanks all for the help.


You want to implement the UITableView delegate method didSelectRowAtIndex. Here's an example:

- (void)tableView:(UITableView *)aTableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
        DetailViewController *detailViewController = [[DetailViewController alloc] init];
        [detailViewController setData:[tableViewData objectAtIndex:[indexPath row]]];
        [[self navigationController] pushViewController:detailViewController animated:YES];     
        [detailViewController release];
}

In your DetailViewController.m file, once you're finished with it, simply use

[self dismissModalViewControllerAnimated:YES];

to pop it off the stack.

0

精彩评论

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