我想使用parse.com将一些对象从tableview传递给视图控制器。我尝试了这个,但它不起作用:我做错了什么?有任何想法吗?我添加了我的详细控制器.m和.h文件以及谢谢..
-(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];
}
my 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
答案 0 :(得分:0)
Per Apple's documentation,看起来NIB / XIB中的所有出口都应该在NIB / XIB中的任何对象上调用awakeFromNib
之前连接,但是出口在对象上调用没有连线。您必须将值传递给某些强大的属性,并在awakeFromNib中执行所有操作。init
等时,可能
- (void)awakeFromNib
{
self.label1.text = self.columnText;
}
答案 1 :(得分:0)
解决。我创建了一个单独的属性,例如MyTableViewDetail中的“columntext”,然后是
set MTD.columntext = [object objectForKey:@"columntext"];,
set self.label1.text = self.columntext; in viewDidLoad of MyTableViewDetail.