ios - setHidden not working for UIView -
i have subclass of uiview
called invitedview
. instantiated in viewdidload
this:
viewcontroller.m
invitedview = [[invitedview alloc] initwithframe:cgrectmake(100, 244, 120, 80)]; invitedview.backgroundcolor = [uicolor colorwithred:156.0f/255.0f green:214.0f/255.0f blue:215.0f/255.0f alpha:0.9f]; [self.view addsubview:invitedview]; [invitedview sethidden:yes];
the class looks this:
invitedview.m
#import "invitedview.h" #import "appdelegate.h" #import "viewcontroller.h" @class viewcontroller; @interface invitedview() { uibutton *accept; uibutton *decline; uilabel *question; uiview *gray; viewcontroller *myviewcontroller; } @end @implementation invitedview - (id)initwithframe:(cgrect)frame { self = [super initwithframe:frame]; if (self) { gray = [[uiview alloc] initwithframe:frame]; nsstring *holduser = [(appdelegate*)[[uiapplication sharedapplication] delegate] invitedby]; [self addsubview:gray]; accept = [[uibutton alloc] init]; decline = [[uibutton alloc] init]; question = [[uilabel alloc] init]; question.text = [[nsstring alloc] initwithformat:@"you have been invited group game %@", holduser]; question.numberoflines = 0; question.textalignment = nstextalignmentcenter; question.textcolor = [uicolor colorwithred:211.0f/255.0f green:243.0f/255.0f blue:219.0f/255.0f alpha:1.0f]; accept.backgroundcolor = [uicolor clearcolor]; accept.frame = cgrectmake(20, gray.frame.size.height / 2, (gray.frame.size.width / 2) - 10, (gray.frame.size.height / 2) - 20); decline.backgroundcolor = [uicolor clearcolor]; decline.frame = cgrectmake((gray.frame.size.width / 2) + 10, (gray.frame.size.width / 2) - 20, (gray.frame.size.width / 2) - 20, (gray.frame.size.height / 2) - 20); question.frame = cgrectmake(20, 20, gray.frame.size.width, (gray.frame.size.height / 2) - 20); [question setfont:[uifont fontwithname:@"helveticaneue-bold" size:18.0]]; [accept addtarget:myviewcontroller action:@selector(acceptinvite) forcontrolevents:uicontroleventtouchupinside]; [decline addtarget:myviewcontroller action:@selector(declineinvite) forcontrolevents:uicontroleventtouchupinside]; [gray addsubview:accept]; [gray addsubview:decline]; [gray addsubview:question]; } return self; } @end
the method view supposed shown in view controller showing view. ends getting called, can verify log messages happen way until sethidden
function:
viewcontroller.m
- (void)dosomethingwiththenewvalueofflagforhid { nslog(@"issettingtheview******"); dispatch_async(dispatch_get_main_queue(), ^(void){ nslog(@"issettingtheviewmu2******"); [invitedview sethidden:no]; }); }
i know why invitedview
isn't being shown after [invitedview sethidden:no]
. gets way sethidden
, , nothing happens. appreciate help, in advance.
in viewdidload
, change line
[invitedview sethidden:no];
to make sure can see view (frame ok, no view above ...)
you might want check xcodes 3d view debugging
Comments
Post a Comment