I'm new in Objective-C, I try to code an iPad App (Objective-C 2.0, Xcode 4.0.1). I "play" with ActionSheet to understand how it works. In a nib file I put a button binded to my "buttonPressed" method.
I've written this code :
-(IBAction)buttonPressed
{
UIActionSheet *myActionSheet = [[UIActionSheet alloc] initWithTitle:@"My Action Sheet" delegate:nil cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"OK" otherButtonTitles:@"Test", nil];
NSLog([NSString stringWithFormat:@"%d", [myActionSheet numberOfButtons]]);
NSLog([myActionSheet buttonTitleAtIndex:0]);
NSLog([myActionSheet buttonTitleAtIndex:1]);
NSLog([myActionSheet buttonTitleAtIndex:2]);
[myActionSheet showInView:self.view];
[myActionSheet release];
}
This is the NSLog result :
2011-04-14 14:52:30.428 TrampManage[3568:207] 3
2011-04-14 14:52:30.429 TrampManage[3568:207] OK
2011-04-14 14:52:30.430 TrampManage[3568:207] Test
2011-04-14 14:52:30.432 TrampManage[3568:207] Cancel
But the displayed view is quiet different (cf image : http://www.imagup.com/data/1117452257.html). For the moment, I've one simple question : Why my "Cancel" button doesn't appear ?