iphone - Subview with UIButton isn't clickable -


here's code i'm working with:

uibutton *mainbutton = [[uibutton alloc] initwithframe:cgrectmake(0, 0, 100, 100)]; [mainbutton setimage:[uiimage imagenamed:@"circleshape.png"] forstate:uicontrolstatenormal]; mainbutton.center = cgpointmake(self.view.frame.size.width/2.0f, self.view.frame.size.height/2.0f); [self.view addsubview:mainbutton];  uiview *subview = [[uiview alloc] initwithframe:cgrectmake(0, 100, 200, 100)]; [subview setbackgroundcolor:[uicolor purplecolor]]; [mainbutton addsubview:subview];  uibutton *secondbutton = [[uibutton alloc] initwithframe:cgrectmake(0, 0, 100, 100)]; [secondbutton setimage:[uiimage imagenamed:@"circleshape.png"] forstate:uicontrolstatenormal]; secondbutton.center = cgpointmake(subview.frame.size.width/2.0f, subview.frame.size.height/2.0f); [subview addsubview:secondbutton]; 

why mainbutton clickable secondbutton isn't?

k should add sub view on self.view.

uiview *subview = [[uiview alloc] initwithframe:cgrectmake(0, 100, 200, 100)]; [subview setbackgroundcolor:[uicolor purplecolor]]; [self.view addsubview:subview];  uibutton *secondbutton = [[uibutton alloc] initwithframe:cgrectmake(0, 0, 100, 100)]; [secondbutton setimage:[uiimage imagenamed:@"circleshape.png"] forstate:uicontrolstatenormal]; secondbutton.center = cgpointmake(subview.frame.size.width/2.0f, subview.frame.size.height/2.0f); [subview addsubview:secondbutton]; uibutton *thirdbutton = [[uibutton alloc] initwithframe:cgrectmake(100, 0, 100, 100)]; [secondbutton setimage:[uiimage imagenamed:@"circleshape.png"] forstate:uicontrolstatenormal]; secondbutton.center = cgpointmake(subview.frame.size.width/2.0f, subview.frame.size.height/2.0f); [subview addsubview:secondbutton]; 

try this. add 2 buttons on subview.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -