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 08-07-2010, 07:51 AM   #1 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 72
santosh_kumar is on a distinguished road
Default Can a Table cell works like a button in iphone?

Hi all, i created a table with custom cell view with each cell containing a button,textfield and label. When a user touches any of these controls say for example label, i need to know which control touched ( like user touched label).
Can we do this? If so please help me.

Thanks in advance.
Santosh.

Last edited by santosh_kumar; 10-13-2010 at 12:11 AM.
santosh_kumar is offline   Reply With Quote
Old 08-07-2010, 09:31 AM   #2 (permalink)
iPhone Developer
 
Join Date: Aug 2009
Posts: 64
losingSkillz is on a distinguished road
Default

create a new file and specify that it subclasses uitableviewcell

xcode will create some methods for you. add the code for buttons, etc in the init method.

finally instead of alloc uitableviewcell in your tableview delegate methods, use your own uitableviewcell subclass instead

hope this helps
__________________
If I helped you in any way, please help me by checking out my apps:

iPower Your Device --- Charge Up your device!

(FREE)


losingSkillz is offline   Reply With Quote
Old 08-09-2010, 01:50 AM   #3 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 72
santosh_kumar is on a distinguished road
Default

Thanks for your reply losingSkillz. I got it as you said but i'm not getting which input field is selected.I have one button and one textfield in every cell, when a user selects textfield i should be able to know that input is coming from textfield.


Quote:
Originally Posted by losingSkillz View Post
create a new file and specify that it subclasses uitableviewcell

xcode will create some methods for you. add the code for buttons, etc in the init method.

finally instead of alloc uitableviewcell in your tableview delegate methods, use your own uitableviewcell subclass instead

hope this helps
santosh_kumar is offline   Reply With Quote
Old 10-13-2010, 12:24 AM   #4 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 72
santosh_kumar is on a distinguished road
Default Table Cell can Work like a button

-(void)touchesBeganNSSet *)touches withEventUIEvent *)event
{


UITouch *touch=[[event allTouches] anyObject];
CGPoint location=[touch locationInView: self];

if(CGRectContainsPoint(label.frame, location))
{

NSLog(@"label touched");

}
}

With this code we can tell which control is selected on the screen.
santosh_kumar is offline   Reply With Quote
Old 10-13-2010, 03:43 PM   #5 (permalink)
iPhone Developer
 
Join Date: Aug 2009
Posts: 64
losingSkillz is on a distinguished road
Default

you need to create a delegate class (could be your class with the tableview) so that when a user touches any textfield or button, your delegate class will receive the call.

also you might need an identifier so that you know which cell was tapped. you could define it in the header (a string or something)

hope this helps
__________________
If I helped you in any way, please help me by checking out my apps:

iPower Your Device --- Charge Up your device!

(FREE)


losingSkillz is offline   Reply With Quote
Reply

Bookmarks

Tags
iphone & ipod touch apps

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: 310
9 members and 301 guests
arash5500, gordo26, HemiMG, linkmx, mediaspree, nobstudio, Objective Zero, stanny, Touchmint
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,655
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, pungs
Powered by vBadvanced CMPS v3.1.0

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