mwaterfall / MWPhotoBrowser

A simple iOS photo and video browser with grid view, captions and selections.
MIT License
8.75k stars 2.72k forks source link

underlyingImage Crash #33

Closed alexstanbury closed 12 years ago

alexstanbury commented 12 years ago

I'm adding the MWPhotobrowser to my project using urls to files on the device. When I push the view controller I get the following error:

-[NSCFDictionary underlyingImage]: unrecognized selector sent to instance 0xce034f0 Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFDictionary underlyingImage]: unrecognized selector sent to instance 0xce034f0' *\ First throw call stack: (0x16bd052 0x198fd0a 0x16beced 0x1623f00 0x1623ce2 0x7a007 0x80897 0x806b9 0x7b398 0x7a9ed 0x78085 0x79a20 0x7751f 0x7c964e 0x7c9941 0x7db47d 0x7db66f 0x7db93b 0x7dc3df 0x7dc561 0x8f84ca 0x742301 0x16bee72 0x62292d 0x62c827 0x5b2fa7 0x5b4ea6 0x5b4580 0x16919ce 0x1628670 0x15f44f6 0x15f3db4 0x15f3ccb 0x2438879 0x243893e 0x703a9b 0x2bb0 0x23d5 0x1) terminate called throwing an exception(lldb)

I should add that this project uses ARC, but I have disabled ARC for this library as well as SDWebImage using the appropriate compiler flag.

Any suggestions?

alexstanbury commented 12 years ago

It appears the photo object being passed to this method is not an instance of MWPhoto as needed :

mwaterfall commented 12 years ago

Hi Alex. Yes that's what I could see from the exception, seems to be an NSDictionary.

I'm not sure what's happening there as I haven't been able to recreate the problem. Is this easily reproducible your end? If you can get it to happen on the demo project then I'll be able to look into it.

Cheers!

Lucas-Lallement commented 11 years ago

Still a problem for me

daddymac72 commented 9 years ago

i am getting this error. Was there ever anything figured out?

paulmiard commented 9 years ago

@daddymac72 You need to use the array of MWPhoto in your delegate methods as well. If you use an array of URL strings or dictionaries, this will happen.

shashidev commented 8 years ago

Hi, I am trying to add MWPhotoBrowser but getting an exception.

erminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString underlyingImage]: unrecognized selector sent to instance 0x14a3c8' *\ First throw call stack: (0x23f2db0b 0x236eadff 0x23f33455 0x23f310ab 0x23e5b298 0x113c53 0x10cf3d 0x10f9ef 0x10ba93 0x2850ba35 0x28523cd5 0x286bb561 0x285c89ef 0x285c8701 0x285c8677 0x285076fb 0x26578569 0x26573d2d 0x26573bbd 0x26573081 0x26572d55 0x284fe7f5 0x23eef2b1 0x23eed5a7 0x23eed9e5 0x23e3c1c9 0x23e3bfbd 0x25458af9 0x28574435 0xf72f5 0x23ae8873)

I have wrote the code as follow:

import "ViewController.h"

import "MWPhotoBrowser.h"

import "MWCommon.h"

@interface ViewController ()<UITableViewDelegate,UITableViewDataSource,MWPhotoBrowserDelegate> { NSMutableArray myPhotos; } @property (strong, nonatomic) IBOutlet UITableView galleryTableView; @property(nonatomic,retain)NSMutableArray *photos;

@end

@implementation ViewController

} -(NSInteger)tableView:(UITableView )tableView numberOfRowsInSection:(NSInteger)section { return myPhotos.count; } -(UITableViewCell)tableView:(UITableView )tableView cellForRowAtIndexPath:(NSIndexPath )indexPath { UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"cell"];

if(!cell)
{
    cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
}

UIImageView *aImageView=(UIImageView*)[cell.contentView viewWithTag:100];

aImageView.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@",[myPhotos objectAtIndex:indexPath.row]]];
return cell;

} -(void)tableView:(UITableView )tableView didSelectRowAtIndexPath:(NSIndexPath )indexPath {

BOOL displayActionButton = YES;
BOOL displaySelectionButtons = NO;
BOOL displayNavArrows = NO;
BOOL enableGrid = YES;
BOOL startOnGrid = NO;

_photos =myPhotos;

// Create browser
MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
browser.displayActionButton = displayActionButton;
browser.displayNavArrows = displayNavArrows;
browser.displaySelectionButtons = displaySelectionButtons;
browser.alwaysShowControls = displaySelectionButtons;
browser.zoomPhotosToFill = YES;

if IPHONE_OS_VERSION_MIN_REQUIRED < IPHONE_7_0

browser.wantsFullScreenLayout = YES;

endif

browser.enableGrid = enableGrid;
browser.startOnGrid = startOnGrid;
browser.enableSwipeToDismiss = YES;
[browser setCurrentPhotoIndex:indexPath.row];
[self.navigationController pushViewController:browser animated:YES];

}

@end

Please provide us the solution.

MrCoderDing commented 8 years ago

I have solved problem.This method :

} mast return object of MWPhoto Class

ps20002000 commented 7 years ago

SOLVED !!!

You just need to populate the array by creating MWPhoto object as shown.

photos = [[NSMutableArray alloc]init];       // NSMutable array for displaying MWPhotos
MWPhoto *photo;

MWPhoto *photo;

photo = [MWPhoto photoWithImage:[UIImage imageNamed:@"1"]];

[photos addObject:photo];

photo = [MWPhoto photoWithImage:[UIImage imageNamed:@"2"]];

[photos addObject:photo];

photo = [MWPhoto photoWithImage:[UIImage imageNamed:@"3"]];

[photos addObject:photo];

photo = [MWPhoto photoWithImage:[UIImage imageNamed:@"4"]];

[photos addObject:photo];

NSLog(@"%@",photos);

Happie Coding :)