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 01-21-2012, 06:52 AM   #1 (permalink)
Velvet Rock Apps
 
Join Date: Sep 2010
Posts: 231
ChrisYates is on a distinguished road
Default Enlarge Button Programatically, Hit Area Stays The Same?

So I'm finding this a bit weird. I have a ScrollView, the subviews are a UIView and a Button. I used a custom button and noticed that when a user scrolls the button moved within the scrollview (not my intention) which of course it would!

It is my intention that the scrollview holds an image from the users photo library. However the user may scroll their photo which causes the button to move with it, therefore if they decide to add a different photo to that scrollview the button doesn't react as it's no longer in that pat of the scrollview.

As a workaround I decided to change the size of the button when a user picks from their photo library to match the size of the image. This works, I can see that the button size has changed and when the user scrolls their image the button is still there. However here's the problem, it would seem that the button hit area doesn't change, so even though the button is showing it doesn't react unless I scroll to it's original position within the scrollview.

Any help would be greatly received.

Here's some code I'm currently using:

Code:
if (photo1Holder.image.size.width >= photo1Holder.image.size.height){
        
            [photo1 setContentSize:CGSizeMake(207, 128)];
            photo1.zoomScale = 1.00;
            UIGraphicsBeginImageContext(CGSizeMake(620,465));
            [photo1Holder.image drawInRect:CGRectMake(0,0,620,465)];
            UIImage* newImage =      UIGraphicsGetImageFromCurrentImageContext();
            UIGraphicsEndImageContext();
            photo1Holder.image = newImage;
            photoButton1.frame = CGRectMake(0, 0, 207, 128); //This is where I resize my button.
            
            photo1.zoomScale = 1.00;
            [photo1 setContentSize:CGSizeMake(207, 128)];
            
            
        
        }
__________________
Screen Pimp - iPhone
LightsOut! - iPad
LightsOut Pocket - iPhone
Postage UK HD - iPad
Halves HD - iPad
ChrisYates is offline   Reply With Quote
Old 01-21-2012, 09:22 AM   #2 (permalink)
Velvet Rock Apps
 
Join Date: Sep 2010
Posts: 231
ChrisYates is on a distinguished road
Default

Okay solved this one. What I didn't realise was I had placed the button in the UIView, the UIView is a certain size so no matter what size I made the button it would only register touch events with the same dimensions as the view.

I took the button outside of the uiview, scaled it to a much larger size and everything now works.
__________________
Screen Pimp - iPhone
LightsOut! - iPad
LightsOut Pocket - iPhone
Postage UK HD - iPad
Halves HD - iPad
ChrisYates is offline   Reply With Quote
Reply

Bookmarks

Tags
button hit area, scrollview, uibutton

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: 390
10 members and 380 guests
7twenty7, Atatator, FrankWeller, glenn_sayers, guusleijsten, iphonedevshani, MAMN84, QuantumDoja, tim0504, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,674
Threads: 94,122
Posts: 402,907
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Atatator
Powered by vBadvanced CMPS v3.1.0

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