tags:

views:

82

answers:

1

HI,

I am trying to create buttons and text views on touch events from WebView. I am creating the Button creation code in below code.

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

}

capturng of the touch events is happening properly and above fucntion is called also. But the button creation is not happening.

PLease suggest that what could be the issue with approach.

A: 

U have to call a function within this function like this :

-(void)touchesBegan: ( NSSet* )touches withEvent : (UIEvent ) event { [self createButton]; }

and define it like this, this will create a UIButton Dynamically.

-(IBAction) createButton { //create a new dynamic button

CGRect frame = CGRectMake(10, 10, 100, 30);

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];

button.frame = frame;

[button setTitle:(NSString *)@"new button" forState:(UIControlState)UIControlStateNormal];

[button addTarget:self action:nil forControlEvents:nil];

[self.view addSubview:button];

}

U can do whatever you want in this createButton.....

iDev