Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8823023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:15:05+00:00 2026-06-14T06:15:05+00:00

I am now getting only 1 error in GalleryScrollView.m. I think I’m declaring the

  • 0

I am now getting only 1 error in GalleryScrollView.m. I think I’m declaring the Gallery button wrong.

The error is:

Instance Method -initwithFrame:imageName:imgname not found

With this line:

 GalleryButton *btnAttachment = [[GalleryButton alloc] initWithFrame:CGRectMake(startX, startY, width, height) imageName:imgName];

I have tried - (void) removeAttachment:(GalleryButton *)button imageName;

but that does not seem to work. Below is my code.

Any comments or answers is of great appreciation.

Thanks.

GalleryScrollView.h

#import <UIKit/UIKit.h>
#import "AttachmentItem.h"
#import "GalleryButton.h"

@protocol GAlleryScrollDelegate;

@interface GalleryScrollView : UIView <GalleryButtonDelegate>

{

id <GAlleryScrollDelegate> delegate;

// MAIN WINDOW WHERE YOU CAN DRAG ICONS
UIView *mainView;

UIScrollView *_scrollView;
NSMutableArray *_attachments;


NSInteger *_totalSize;

UIImageView *_recycleBin;
CGRect recycleBinFrame;
}
@property (nonatomic, retain) id <GAlleryScrollDelegate> delegate;

@property (nonatomic, retain) UIView *mainView;
@property (nonatomic, retain) NSMutableArray *attachments;

@property (nonatomic, retain) UIImageView *recycleBin;
@property (nonatomic) CGRect recycleBinFrame;

- (void) addAttachment:(AttachmentItem *)attachment withImageNamed:(NSString *)imgName;
- (void) removeAttachment:(GalleryButton *)button;
- (void) reloadData;

@end

// EVENTS IF YOU WANT TO DISABLE SOME SCROLL ON DID PRESS AND ENABLE IT ON DROP
@protocol GAlleryScrollDelegate
- (void) didPressButton;
- (void) didDropButton;
@end

GalleryScrollView.m

#import <QuartzCore/QuartzCore.h>
#import "GalleryScrollView.h"
#import "GalleryButton.h"

@implementation GalleryScrollView


@synthesize delegate;
@synthesize mainView;
@synthesize attachments = _attachments;
@synthesize recycleBin = _recycleBin, recycleBinFrame;


int padding = 0;


#pragma mark - INIT

- (id) init
{
self = [super init];
if (self) {
    // Initialization code here.
}
return self;
}

- (id) initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self){
    ;
}
return self;
}

- (void) awakeFromNib
{
// INIT ATTACHMENT ARRAY
if (_attachments == nil){
    _attachments = [[NSMutableArray alloc] init];
}

// SCROLL VIEW
UIScrollView *scrollTemp = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width-0, 450)];
_scrollView = scrollTemp;
_scrollView.backgroundColor = [UIColor clearColor];

// RECYCLE BIN
UIImageView *imageViewTemp = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mozambique-wenge.png"]];
self.recycleBin = imageViewTemp;
self.recycleBin.frame = CGRectMake(0, 0, 320, 270);

[self addSubview:_scrollView];
[self addSubview:self.recycleBin];
[scrollTemp release];
[imageViewTemp release];
}

- (void) dealloc {
[super dealloc];

}

#pragma mark - ATTACHMENTS ADD / REMOVE

- (void) addAttachment:(AttachmentItem *)attachment withImageNamed:(NSString *)imgName
{
// SAVE ATTACHMENT
[_attachments addObject:attachment];

// RESIZE CONTENT VIEW FOR INSERTINT NEW ATTACHMENT
_scrollView.contentSize = CGSizeMake([_attachments count]*70, 70);

CGFloat startX = (70.0f * ((float)[_attachments count] - 1.0f) + padding);
CGFloat startY = 370;
CGFloat width = 64;
CGFloat height = 64;

GalleryButton *btnAttachment = [[GalleryButton alloc] initWithFrame:CGRectMake(startX, startY, width, height) imageName:imgName];
btnAttachment.tag = [_attachments count];
btnAttachment.scrollParent = _scrollView;
btnAttachment.mainView = self.mainView;
btnAttachment.delegate = self;

if (attachment.type == 1){
}else if (attachment.type == 2){
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 64, 64)];
    imageView.image=[UIImage imageNamed:@"mozambique-wenge"];
    [btnAttachment addSubview:imageView];
    [imageView release];
} else if (attachment.type == 3){
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 64, 64)];
    imageView.image=[UIImage imageNamed:@"recyclebin.png"];
    [btnAttachment addSubview:imageView];
    [imageView release];
}

[_scrollView addSubview:btnAttachment];
[btnAttachment release];

}


- (void) removeAttachment:(GalleryButton *)button
{

}

#pragma mark - RELOAD DATA

- (void) reloadData
{

}

#pragma mark - GALLERY BUTTON DELEGATE

-(void) touchDown
{
[self.delegate didPressButton];
}

-(void) touchUp
{
[self.delegate didDropButton];
_scrollView.scrollEnabled = YES;
}

-(BOOL) isInsideRecycleBin:(GalleryButton *)button touching:(BOOL)finished;
{
CGPoint newLoc = [self convertPoint:self.recycleBin.frame.origin toView:self.mainView];
CGRect binFrame = self.recycleBin.frame;
binFrame.origin = newLoc;

if (CGRectIntersectsRect(binFrame, button.frame) == TRUE){
    if (finished){
        [self removeAttachment:button];
    }
    return YES;
}
else {
    return NO;
}

}

@end

GalleryButton.m

#import <QuartzCore/QuartzCore.h>
#import "GalleryButton.h"
#import "GalleryScrollView.h"

@implementation GalleryButton

@synthesize delegate;
@synthesize originalPosition = _originalPosition;
@synthesize mainView, scrollParent;
@synthesize images;

- (id)init
{
self = [super init];
if (self) {
    // Initialization code here.
}

return self;
}

- (id)initWithFrame:(CGRect)frame imageName:(NSString *)imgName
{
self = [super initWithFrame:frame];
if (self) {
    isInScrollview  = YES;

    CGRect myImageRect = CGRectMake(0, 0, 64, 64);
    images = [[UIImageView alloc] initWithFrame:myImageRect];

    // here's the change:
    // instead of a constant name, use the `imgName` parameter
    [images setImage:[UIImage imageNamed:imgName]];
    [self addSubview:images];

    self.backgroundColor = [UIColor blackColor];
    self.layer.borderWidth = 2;
    self.layer.borderColor = [UIColor blackColor].CGColor;
    self.layer.masksToBounds = YES;
    self.layer.cornerRadius = 5;
}
return self;
}
#pragma mark - DRAG AND DROP

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

[self.delegate touchDown];
self.originalPosition = self.center;
self.scrollParent.scrollEnabled = NO;

if (isInScrollview == YES) {
    CGPoint newLoc = CGPointZero;
    newLoc = [[self superview] convertPoint:self.center toView:self.mainView];
    _originalOutsidePosition = newLoc;

    //      [self.superview touchesCancelled:touches withEvent:event];
    [self removeFromSuperview];

    self.center = newLoc;
    [self.mainView addSubview:self];
    [self.mainView bringSubviewToFront:self];
    isInScrollview = NO;
}
else {
    ;
}

}

-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {

[UIView beginAnimations:@"stalk" context:nil];
[UIView setAnimationDuration:.001];
[UIView setAnimationBeginsFromCurrentState:YES];

UITouch *touch = [touches anyObject];
self.center = [touch locationInView: self.superview];

[UIView commitAnimations];

if ([delegate isInsideRecycleBin:self touching:NO]){

}

}

-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {

if ([delegate isInsideRecycleBin:self touching:YES]){

    CGRect myImageRect = CGRectMake(0, 0, 320, 300);
    images = [[UIImageView alloc] initWithFrame:myImageRect];
    [images setImage:[UIImage imageNamed:@"light-cherry.png"]];
    [self.mainView addSubview:images];

    UIImageView * animation = [[UIImageView alloc] init];
    animation.frame = CGRectMake(self.center.x - 32, self.center.y - 32, 40, 40);

    animation.animationImages = [NSArray arrayWithObjects:
                                 [UIImage imageNamed: @"iconEliminateItem1.png"],
                                 [UIImage imageNamed: @"iconEliminateItem2.png"],
                                 [UIImage imageNamed: @"iconEliminateItem3.png"],
                                 [UIImage imageNamed: @"iconEliminateItem4.png"]
                                 ,nil];
    [animation setAnimationRepeatCount:1];
    [animation setAnimationDuration:0.35];
    [animation startAnimating];
    [self.mainView addSubview:animation];
    [animation bringSubviewToFront:self.mainView];
    [animation release];
    ;
    [UIView beginAnimations:@"goback" context:nil];
    [UIView setAnimationDuration:0.4f];
    [UIView setAnimationBeginsFromCurrentState:YES];
    self.center = _originalOutsidePosition;
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector: @selector(animationDidStop:finished:context:)];
    //        loadingView.frame = CGRectMake(rect.origin.x, rect.origin.y - 80, rect.size.width, rect.size.height);
    [UIView commitAnimations];

} else{
    [UIView beginAnimations:@"goback" context:nil];
    [UIView setAnimationDuration:0.4f];
    [UIView setAnimationBeginsFromCurrentState:YES];
    self.center = _originalOutsidePosition;
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector: @selector(animationDidStop:finished:context:)];
    //        loadingView.frame = CGRectMake(rect.origin.x, rect.origin.y - 80, rect.size.width, rect.size.height);
    [UIView commitAnimations];


}

[self.delegate touchUp];

}

-(void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
if ([animationID isEqualToString:@"goback"] && finished) {
    [self removeFromSuperview];
    self.center = _originalPosition;
    [self.scrollParent addSubview:self];
    isInScrollview = YES;
}
}

@end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:15:06+00:00Added an answer on June 14, 2026 at 6:15 am

    I think the only problem you are facing here is that you didn’t declare your - (id) initWithFrame:(CGRect)frame imageName:(NSString *)imageName method. Make sure you have declare this method in your header file: GalleryButton.h with the same signature.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Now getting error Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT
I had a class loader working although I am now getting an error after
I just upgraded jQuery to version 1.4.2 and I am now getting an error
I've just reorganised my code (which worked before) and am now getting an error
Integrated new RevMob.frmework in Cocos2D games. Now getting many compilation error in my Cocos2D
I recently rebuilt my website and now I'm getting this error: Warning: mysql_result(): supplied
Upgraded an app from 2.3 to 3.0 and now getting these. What's the best
After installing .NET 4.0, I am now getting an exception on this statement: if
We just switched to Glassfish V2. We are now getting errors when setting a
I moved a site from WebAPI Beta to WebAPI RC, and am now getting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.