Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 04-22-2011, 09:18 PM   #1 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 18
sregorcinimod is on a distinguished road
Default call method from subclass of uiimageview

I have two .m files. The first is the main code, The second is a subclass of UIImageView so that i can detect touches.
In the main .m file I have added a progress bar and a customimageview both subviews of a scrollview.

What I need is that when a user touches the customimageview that the progress bar moves up and a double tap decreases the [Note: the customimageview has to have its touches recognised in the second .m because of them being in a subview of a scrollview and other controls are having to be handled]

In the main .m file I have a two methods:

- (void)pumpsingletap {
progbm.progress +=0.1;
}

- (void)pumpdoubletap {
progbm.progress -=0.1;
}

then in the subclassed uiimageview i have:

//inside touches method
if ([touch view].tag == 555) {
NSLog(@"pump touched");
switch ([allTouches count]) {
case 1: {
switch ([touch tapCount]) {
//---single tap---
case 1: {
NSLog(@"single pump touch");
[self performSelector:@selector(pumpsingletap) withObject:nil afterDelay:.4];
} break;
//---double tap---
case 2: {
NSLog(@"double pump touch");
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(pumpsingletap) object:nil];
[self performSelector:@selector(pumpdoubletap) withObject:nil afterDelay:.4];
} break;
}
}
}
}

So the NSlog's appear so the touch recognition isn't an issue. But the performSelector falls over. As the customimageview pumpsingletap doesnt work.

So how do i call the method in the subclass
sregorcinimod is offline   Reply With Quote
Old 04-22-2011, 11:55 PM   #2 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 18
sregorcinimod is on a distinguished road
Default method called but progress bar not moving

o I have added in the following code, in my subclass

mainMethod* callingMethod = [[mainMethod alloc] init];
[callingMethod performSelector:@selector(pumpsingletap) withObject:nil afterDelay:.4];

then in my main method for pumpsingletap i changed it to:

- (void)pumpsingletap {
NSLog(@"single pump method called");
progbm.progress +=0.1;
}

The NSLog for single pump method called appeared but the progress bar progbm - didn't move. so i have solved my calling issue - just need to now work out why the progress bar isnt moving!!
sregorcinimod is offline   Reply With Quote
Old 04-23-2011, 12:02 AM   #3 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

Please use [code] tags when posting source code.

Is the progress bar added through code or in IB? If latter, is the outlet connected properly, and in case of former where and how did you initialize the progress bar?

Also, what are the Min and Max values of the progressbar? Maybe 0.1 increments are too small to be noticeable, try setting it to 5, 10 or something and see if it has any effect.
baja_yu is offline   Reply With Quote
Old 04-23-2011, 12:48 AM   #4 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 18
sregorcinimod is on a distinguished road
Default

The progress bar is added through code and the min value is 0.0 and max value 1.0.

If i intiate the pumpsingletap from with the main .m file the progress bar updates.

It's only if i call the pumpsingletap from the subclassed uiimageview that it doesn't work.
sregorcinimod is offline   Reply With Quote
Old 04-23-2011, 01:12 AM   #5 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

Are you sure 'progbm' is pointing to the right object, if anything at all?

Try putting this in the methods and see what the output will be

NSLog(@"progbm: %@", progbm);
baja_yu is offline   Reply With Quote
Old 04-23-2011, 04:44 PM   #6 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 18
sregorcinimod is on a distinguished road
Default

If i add in the NSLog(@"progbm: %@", progbm)

it returns null.

Why would that be when the progbm is in the main viewcontroller .m and the -(void)pumpsingletap method is in the main viewcontroller.m
sregorcinimod is offline   Reply With Quote
Old 04-23-2011, 09:58 PM   #7 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 18
sregorcinimod is on a distinguished road
Thumbs up

So I solved it by adding in NSNotifications and sending a notification from the subclass to the main view controller
sregorcinimod is offline   Reply With Quote
Reply

Bookmarks

Tags
class, method, subclass, touch

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 343
12 members and 331 guests
dansparrow, iOS.Lover, lorrettaui53, Nobbsy, Objective Zero, oztemel, pbart, PlutoPrime, samdanielblr, sledzeppelin, thephotographer, Trickphotostudios
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,119
Posts: 402,896
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:50 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0