In my application, i'm using a customised table. Each cell have an uibutton and uiimage. When a touch up accurs at the button, i want to call the uiimagepickercontroller method to select a picture from the iphone library and display it in the image view. I've written it but getting a warning... 'customCell' may not respond to presentmodalviewcontroller animated... here customCell is the subclass of my main class, myApp, also the name of the nib of the custom cell. Anyone knows the issue???? Thanks...
EDIT
- (IBAction)selectExistingPicture1 {
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypePhotoLibrary]) {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsImageEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:picker animated:YES];
[picker release];
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error accessing photo library" message:@"Device does not support a photo library" delegate:nil cancelButtonTitle:@"Drat!" otherButtonTitles:nil];
[alert show];
[alert release];
}
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
CGSize newSize = CGSizeMake(80, 80);
UIGraphicsBeginImageContext( newSize );
[image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
imageView.image = newImage;
[picker dismissModalViewControllerAnimated:YES]; //warning shown here
}
This is the custom cell class.. and the viewController class has...
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CustomCellIdentifier = @"CustomCellIdentifier";
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:CustomCellIdentifier];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:nil options:nil];
for (id currentObject in nib){
if ([currentObject isKindOfClass:[CustomCell class]]){
cell = (CustomCell *)currentObject; break;
}
}
}
NSUInteger s= indexPath.section;
//[cell setText:[NSString stringWithFormat:@"I am cell %d", indexPath.row]];
NSUInteger r = indexPath.row;
cell.imageView.image = nil;
for (s;s==0;s++)
for(r;r==0;r++)
{
UIImage *img=imageView.image;
cell.imageView.image = img;
}
return cell;
}