开发者

UIActionSheet Customization

UIActionSheet Customization

Can you control the size of the text and it's alignment on the action s开发者_如何学JAVAheet? 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


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜