我能够从一个名为dogs的mysql中使用xml解析数组来启动和加载我的表,但当我点击该单元格时,它拒绝执行segue到下一个视图控制器(称为loadingViewController)来显示该行在标签中(与单元格中的结果相同)。我相信我已正确设置故事板。
ViewController.m
#import "ViewController.h"
#import "LoadingViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)dealloc
{
[super dealloc];
if ( dogs )
[dogs release];
- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section {
if ( dogs != NULL ) {
return [dogs count];
}
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"MyIdentifier"] autorelease];
}
NSDictionary *itemAtIndex = (NSDictionary *)[dogs objectAtIndex:indexPath.row];
UILabel *newCellLabel = [cell textLabel];
[newCellLabel setText:[itemAtIndex objectForKey:@"name"]];
return cell;
}
-(method for calling to my mysql here. Below is how I successfully parse the returned results)
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {
if ( [elementName isEqualToString:@"dog"]) {
[dogs addObject:[[NSDictionary alloc] initWithDictionary:attributeDict]];
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:@"showDetail" sender:[NSString stringWith:dogs]];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"showDetail"]) {
NSIndexPath *indexPath = [self->tableView indexPathForSelectedRow];
LoadingViewController *destViewController = segue.destinationViewController;
destViewController.typeLabel = [dogs objectAtIndex:indexPath.row];
}
}
LoadingViewController.h-只是标签的属性和nsstring dog的属性 LoadingViewController.m-刚刚合成的命令