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 06-02-2010, 02:26 PM   #1 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 2
mihai is on a distinguished road
Default Action for dynamically created UIButton inside UITextView

Hello,

I have a scroll view; inside I add one or more text views; to each text view I add button:
HTML Code:
UIScrollView
   UITexView
       UIButton
   UITextView
      UIButton
   ...
This is part of the code:
Code:
- (void)viewDidLoad {
   ...
   [self loadUI];
   ...
}

-(void) loadUI {
   UITextView *textView;
   ...
   for (...) {
      UIButton *editButton = [[UIButton alloc] initWithFrame:
CGRectMake(self.scrollView.frame.size.width - 230, 0, 50, 20)];
      ...
      [editButton addTarget:self action:@selector(editPressed:) 
forControlEvents:UIControlEventTouchUpInside];
      ...
      textView = [[CustomTextView alloc] initWithFrame:
CGRectMake(10, dynamicHeight, self.queuedView.frame.size.width - 100, 500)];
      textView.userInteractionEnabled = NO; //changing to YES doesn't make any difference
      ...
      [textView addSubview:editButton];
      [editButton release];
      ...
      [self.scrollView addSubview:textView];
      [textView release];
   }
}

- (IBAction) editPressed:(id)sender {
   ...
}
For some reason, the editPressed method is not called when I press the button. Any ideas why? I changed form (IBAction) to (void), still nothing.

Thank you,
Mihai
mihai is offline   Reply With Quote
Old 06-02-2010, 03:03 PM   #2 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 2
mihai is on a distinguished road
Default

Apparently, textView.userInteractionEnabled = YES; did the trick. I tried this before but it did not work. Maybe I had to do a clean build after the change.
mihai is offline   Reply With Quote
Reply

Bookmarks

Tags
uibutton, uiscrollview, uitextview

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: 351
13 members and 338 guests
ajay123123, Anwerbl, Arty Tales, ashaman64, baja_yu, ChrisYates, HemiMG, mini998, mottdog, newDev, Objective Zero, oceanlablight, Steven.C
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,878
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

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