2010-03-10 2 views
0

Я написал код для действия кнопки. Сначала я создаю кнопку "UI", а ее onAction следует позвонить ButtonListener в @selector в addTarget. Но, похоже, он не вводит метод @selector(UIButtonListener).Почему поток управления не входит в @selector (имя метода)?

Вот мой код:

UIButton_G_obj = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain]; 
UIButton_G_obj.frame = CGRectMake(100,30,100,50); 
[UIButton_G_obj setTitle:@"UI" forState:UIControlStateNormal]; 
UIButton_G_obj.backgroundColor = [UIColor clearColor]; 
[subMainView_obj addSubview:UIButton_G_obj]; 
[UIButton_G_obj addTarget:self action:@selector(UIButtonListener) forControlEvents:UIControlEventTouchUpInside]; 

-(void)UIButtonListener 
{ 
NSArray *array = [subUiCtxt_G_obj getMList]; 
int count ; 
for (NSString *string in array) 
{ 
    count ++; 
} 

int w=100,x=30,y=100,z=50; 
//set view property ov controller to the newly created view 
if(count>0) 
{ 
    for(NSString *st in array) 
    { 
    // create Button's for modules in array (UIButtonTypeRoundedRect) 
    UIButton_G_obj = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain]; 
    UIButton_G_obj.frame = CGRectMake(w,x,y,z); 
    [UIButton_G_obj setTitle:st forState:UIControlStateNormal]; 
    UIButton_G_obj.backgroundColor = [UIColor clearColor]; 
    [mainView_G_obj addSubview:UIButton_G_obj]; 
    x=+70; 
    } 
} 
} 

ответ

0

Попробуйте

[UIButton_G_obj addTarget:self action:@selector(UIButtonListener:) forControlEvents:UIControlEventTouchUpInside]; 

-(void)UIButtonListener:(id)sender 
Смежные вопросы