开发者

I need to figure out multiple UIActionsSheets?

I am trying to create multiple UIActions sheets with my view. I have read a few questions on here and browsed the internet, but nothing seems to get me a valid answer.

I have tried the "switch and case" method that looks like this....

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
switch (actionSheet.tag) {
    case 10:

    if(buttonIndex == 0)
    {

and I have tried this method too...

UIActionSheet *actionSheet1;
UIActionSheet *actionSheet2;
 - (void)actionSheet:(UIActionSheet 开发者_JAVA百科*)actionSheet clickedButtonAtIndex:        (NSInteger)buttonIndex{
if(actionSheet==actionSheet1)
{

The action sheet options work as individuals, so I know that the links and code is right, but I can't seem to get them both to work at the same time.

Let me know if I need to post more code.

Cheers Jeff


More Info:

-(IBAction)Action01:(id)sender {
UIActionSheet *actionSheet1 = [[UIActionSheet alloc] initWithTitle:@"Please Choose a Website:" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Facebook",@"Twitter",@"Google Maps",nil];
actionSheet1.tag = 10;
[actionSheet1 showInView:self.view];

}

and the second one is set up with tag = 11.O have also linked the buttons in Interface Builder with the same tag number.

In my heads file, I have defined my properties and IB Actions as well. Everything is done properly as it works if i use only one or the other of the action sheets and comment the rest out.

Here are the links to the files if it makes them easier:

Header file

Implementation file

Cheers Jeff


You mention in your updated post that you have set the tags in Interface Builder and in code. This is likely causing a conflict. You don't want those IB buttons to have the same tags as the action sheet, or strange thing will happen.

Change the tags in Interface Builder and that should solve your problem.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜