views:

10

answers:

1

alt textCan you control the size of the text and it's alignment on the action sheet? Also, Can you decide the order in which the destructivebutton and otherbuttons will appear on the action sheet? The screenshot like screen is what I am trying to create.

Thanks in advance

A: 

I did something like this to customize an Action Sheet:

-(void) showPopup { unitPicker *pc = [[unitPicker alloc] init]; UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:@"Units" delegate:pc cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil ];

[pc setParent:self];
popupQuery.actionSheetStyle = UIActionSheetStyleBlackOpaque;    
[popupQuery showInView:self.view];

[popupQuery setBounds:CGRectMake(0,0,320, 350)];

[pc setAs:popupQuery];
[popupQuery addSubview:pc.view];

}

The trick being that "unitPicker" was derived from a UIControllerView, but implemented the UIActionSheetDelegate protocol. It supplied the two functions:

- (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex;
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex;

To deal with any cleanup. The big part was that the format of unitPicker was created from a NIB, as it would with any UIViewController.

The buttons in the view dismissed the actionSheet with the code in their touchUpInside handlers:

[as dismissWithClickedButtonIndex:0 animated:TRUE];

(You can see in the code above that "as" was set to be the actionSheet object).

Brad