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
Post a Comment