0
我寫了一些按鈕操作的代碼。首先,我創建一個按鈕"UI"
,其onAction
應撥打電話ButtonListener
@selector
,addTarget
。但它似乎並沒有進入@selector(UIButtonListener)
方法。爲什麼控制流程不會輸入@selector(methodname)?
這裏是我的代碼:
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;
}
}
}