[英]Cant load detailViewController from tableview
I have a table view loading a sqldata file that displays labels and a image in the cells. 我有一个加载sqldata文件的表视图,该文件在单元格中显示标签和图像。 I wish to load th image and other data into the next vc but cant seem to even get a log to pull back the file time so have no chance of pushing it over.
我希望将图像和其他数据加载到下一个vc中,但似乎什至无法获得日志来拉回文件时间,因此没有机会将其推后。 It is all being done programatically so finding it a little harder.
都是以编程方式完成的,因此很难找到它。 All help appreciated!!!
所有帮助表示赞赏!!!
//Table view
//表格视图
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath >*)indexPath { [self.tableView deselectRowAtIndexPath:indexPath animated:YES]; ATPictureViewController *newView = [[ATPictureViewController alloc] init]; newView.mainImageView.image=[tableView >cellForRowAtIndexPath:indexPath].imageView.image ; [self.navigationController pushViewController:newView animated:YES]; // NSLog(@"Log33 %@",); } @end
I thought this was it 我以为是这样
newView.mainImageView.image=[tableView cellForRowAtIndexPath:indexPath].imageView.image; newView.mainImageView.image = [tableView cellForRowAtIndexPath:indexPath] .imageView.image;
but brings me nothing 但是什么都没带给我
//vc.h #import <UIKit/UIKit.h> @interface ATPictureViewController : UIViewController{ UIImageView *mainImage; } @property (strong, nonatomic) UIImageView *mainImageView; @end
not sure if i call something here 不知道我是否在这里打电话
//vc.m - (void)viewDidLoad { [super viewDidLoad]; self.mainImageView = [[UIImageView alloc] initWithFrame:CGRectMake(50, 50, 200, 200)]; [self.view addSubview:self.mainImageView]; self.mainImageView.image = ???????????
There is at least one problem, maybe two. 至少有一个问题,也许是两个。 First, you can't set the image of mainImageView in your didSelectRowAtIndexPath method, because ATPictureViewController's view hasn't been loaded at that point, and its mainImageView property will be nil.
首先,您不能在didSelectRowAtIndexPath方法中设置mainImageView的图像,因为那时尚未加载ATPictureViewController的视图,并且其mainImageView属性将为nil。 Instead, you should create a UIImage property in ATPictureViewController, and assign the value of that to [tableView cellForRowAtIndexPath:indexPath].imageView.image in didSelectRowAtIndexPath.
相反,您应该在ATPictureViewController中创建UIImage属性,并将其值分配给didSelectRowAtIndexPath中的[tableView cellForRowAtIndexPath:indexPath] .imageView.image。 You can then set the image of mainImageView in ATPictureViewController's viewDidLoad method.
然后,您可以在ATPictureViewController的viewDidLoad方法中设置mainImageView的图像。
Another possible problem is using alloc init to instantiate newView. 另一个可能的问题是使用alloc init实例化newView。 Depending on where you made your view for that controller, you'll probably get a blank view.
根据为该控制器创建视图的位置,您可能会得到空白视图。 You should probably use initWithNibName:bundle: if you made you view in a xib, or instantiateViewControllerWithIdentifier: if you made it in a storyboard.
您可能应该使用initWithNibName:bundle:如果您是在xib中查看的,或者您可以使用InstantiateViewControllerWithIdentifier:如果是在情节提要中进行的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.