Objective c WYPopoverController:如何将图像传递给popover
我在UICollectionView中显示文章,用一个按钮打开WYPOPCovercontroller,用户可以在其中放大图像 为了避免两次下载图像,我尝试将图像从UICollectionView传递到popover,但它不起作用:Objective c WYPopoverController:如何将图像传递给popover,objective-c,uiimage,uicollectionview,Objective C,Uiimage,Uicollectionview,我在UICollectionView中显示文章,用一个按钮打开WYPOPCovercontroller,用户可以在其中放大图像 为了避免两次下载图像,我尝试将图像从UICollectionView传递到popover,但它不起作用: - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ LOAr
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
LOArcticlesCustomCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"MyCell" forIndexPath:indexPath];
[cell.imageView setImageWithURL:[NSURL URLWithString:[[articlesArray objectAtIndex:indexPath.row]objectForKey:@"photoUrl"]]placeholderImage:[UIImage imageNamed:@"simboloLakari29.png"]];
index= indexPath.row;
self.imageArticle = cell.imageView.image;
self.imageUrl = [NSString stringWithString:[[articlesArray objectAtIndex:indexPath.row]objectForKey:@"photoUrl"]];
cell.lblMake.text = [NSString stringWithString:[[articlesArray objectAtIndex:indexPath.row]objectForKey:@"marca"]];
cell.lblMake.lineBreakMode = NSLineBreakByWordWrapping;
cell.lblModel.text = [NSString stringWithString:[[articlesArray objectAtIndex:indexPath.row]objectForKey:@"modelo"]];
cell.lblModel.lineBreakMode = NSLineBreakByWordWrapping;
cell.lblPrice.text = [NSString stringWithString:[[articlesArray objectAtIndex:indexPath.row]objectForKey:@"precio"]];
cell.lblOrder.text = [NSString stringWithFormat:@"%ld de %ld", (unsigned long)indexPath.row+1, (unsigned long)articlesArray.count];
//button magnify position
CGFloat screenHeight = [[UIScreen mainScreen] bounds].size.height;
if (screenHeight == 568) {
cell.magnify.frame = CGRectMake(145.0, 418.0, 30.0, 30.0);
cell.imageView.frame = CGRectMake(20.0, 45.0, 260.0, 260.0);
}
return cell;
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"biggerPicture"])
{
WYStoryboardPopoverSegue* popoverSegue = (WYStoryboardPopoverSegue*)segue;
LOBiggerPictureViewController* destinationViewController = (LOBiggerPictureViewController *)segue.destinationViewController;
destinationViewController.preferredContentSize = CGSizeMake(320, 320);
destinationViewController.imageDownloaded = self.imageArticle;
popoverController = [popoverSegue popoverControllerWithSender:sender permittedArrowDirections:WYPopoverArrowDirectionAny animated:YES];
popoverController.delegate = self;
WYPopoverBackgroundView* appearance = [WYPopoverBackgroundView appearance];
[appearance setTintColor:[UIColor redColor]];
UIColor* popColor = [UIColor colorWithRed:126/255.0 green:34/255.0 blue:110/255.0 alpha:1.0];
WYPopoverBackgroundView* popoverAppearance = [WYPopoverBackgroundView appearance];
[popoverAppearance setOuterCornerRadius:4];
[popoverAppearance setOuterShadowBlurRadius:1];
[popoverAppearance setOuterShadowColor:[UIColor darkGrayColor]];
[popoverAppearance setOuterShadowOffset:CGSizeMake(1, 1)];
[popoverAppearance setGlossShadowColor:[UIColor lightGrayColor]];
[popoverAppearance setGlossShadowOffset:CGSizeMake(1, 1)];
[popoverAppearance setBorderWidth:8];
[popoverAppearance setArrowHeight:10];
[popoverAppearance setArrowBase:20];
[popoverAppearance setInnerCornerRadius:4];
[popoverAppearance setInnerShadowBlurRadius:0];
[popoverAppearance setInnerShadowColor:[UIColor darkTextColor]];
[popoverAppearance setInnerShadowOffset:CGSizeMake(1, 1)];
[popoverAppearance setFillTopColor:popColor];
[popoverAppearance setFillBottomColor:popColor];
[popoverAppearance setOuterStrokeColor:popColor];
[popoverAppearance setInnerStrokeColor:popColor];
UINavigationBar* navBarInPopoverAppearance = [UINavigationBar appearanceWhenContainedIn:[UINavigationController class], [WYPopoverController class], nil];
[navBarInPopoverAppearance setTitleTextAttributes: @{
NSForegroundColorAttributeName : [UIColor clearColor],
NSShadowAttributeName : [UIColor lightGrayColor],
NSShadowAttributeName : [NSValue valueWithUIOffset:UIOffsetMake(0, -1)]}];
}
}
在流行音乐中:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
[self.imageView performSelectorOnMainThread:@selector(setImage:) withObject:imageDownloaded waitUntilDone:YES];
[self.imageView sizeToFit];
self.scrollView.contentSize =self.image.size;
self.scrollView.delegate = self;
self.scrollView.minimumZoomScale = 1.0;
self.scrollView.maximumZoomScale = 3.0;
}
NSLog显示空对象。怎么了?故事板中的弹出框在Xcode 6中有点不推荐使用。你首先要检查的是你对popover的segue,看看“segue”下拉列表上是“popover”还是“Present as popover”。我相信“Popover”有一些东西在iOS8上无法正常工作
如果您的应用程序能够,只需将其更改为“显示为Popover”即可解决此问题。如果您没有该选项,请选中故事板“文件检查器”部分(第一个选项卡)中的“使用大小类”框,将启用新的弹出窗口。尝试设置视图中的图像将显示,而不是视图加载。我想当时prepareforSegue还没有设置这个变量 问题出现在Xcode 5.1上,弹出框显示,但图像不会显示。需要采取你的方法并进行一些测试。如果是Xcode 5,那么你是对的,我的答案并不是真正的解决方案。升级Xcode后,我的故事板弹出框遇到了一些类似的问题。很抱歉