iphone - Need help presenting a view controller -


i have class has extension of uibutton shows uialertview under circumstance.

@interface cellbutton : uibutton {}  uialertview *alert = [[uialertview alloc] initwithtitle:@"you lose!"                                                       message:@"play again?"                                                      delegate:self                                             cancelbuttontitle:@"ok"                                             otherbuttontitles:@"cancel", nil]; [alert show]; 

this works fine, need present view controller when user presses ok.but may know cannot present view controller extension of uibutton.

so wondering if can put code below in viewcontroller , allow work uialert in cellbutton class.

- (void)alertview:(uialertview *)alertview diddismisswithbuttonindex:(nsinteger)buttonindex {     if (buttonindex == 0) {     // , clicked ok.         gamecontroller*mynewvc = [[gamecontroller alloc] init];         [self presentmodalviewcontroller:mynewvc animated:no];     } } 

you don't inside uibutton.

the target of clicking uibutton should uiviewcontroller. after that, show alert view view controller, , view controller delegate of uibutton. work fine.


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -