我想通过parse.com将一些对象从tableview传递给视图控制器。我试过这个,但它不起作用:我做错了什么?有任何想法吗?我说我的细节控制器的.m和.h文件以及感谢你..iOS - 将对象传递给视图控制器
-(void) tableView: (UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSInteger row = [indexPath row];
NSLog(@"%i",row);
PFObject *object = [self objectAtIndex:indexPath];
//Create a DetailViewController object
MyTableViewDetail * MTD = [[MyTableViewDetail alloc] initWithNibName:@"MyTableViewDetail" bundle:nil];
MTD.label1.text =[object objectForKey:@"columntext"];
//push the detail view controller object onto the stack
[self.navigationController pushViewController:MTD animated:YES];
//tableView.backgroundColor =[UIColor clearColor];
}
我detail.h:
@interface MyTableViewDetail : UIViewController{
}
@property (strong, nonatomic) IBOutlet UILabel *label1;
@property (strong, nonatomic) IBOutlet UIImageView *imagedetail;
@end
我.m文件:
#import "MyTableViewDetail.h"
#import "MyTableController.h"
@interface MyTableViewDetail()
@end
@implementation MyTableViewDetail
@synthesize label1;
@synthesize imagedetail;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
-(void)viewDidLoad{
[super viewDidLoad];
}
- (void)viewDidUnload
{
[self setLabel1:nil];
[self setImagedetail:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end
什么是日志输出?你的程序崩溃了吗? –
日志只是选择的行号。运行在模拟器没有所需的输出(不会更改label1。在实际的手机上崩溃..终止应用程序,由于未捕获的异常'NSInternalInconsistencyException',原因:'无法加载捆绑NIB:'NSBundle var/mobile/Applications/F5EACDC2 -35E4-451E-8478-4799xxxxxxxx/name.app>(已装载)'名称'MyTableviewDetail'' – snksnk
最有可能您已经创建并删除表单上的一些控件。删除的控件在之前与某个IBAction/IBOutlet链接因此在笔尖内部变得无效,请尝试在控制器的“界面”构建器中单击控制器的所有者图标,查看是否存在任何无效链接。 –