Amitabha
Amitabha

Reputation: 1662

UIAction Sheet not working on iPad but working in Simulator

I'm having a weird problem. When I run my app on simulator everything works fine but on device some codes are not responding anyway! I have a UIActionSheet which seems pretty good on Simulator, but on device it's not working at all. It even working on iPod:

Here is my code to show action sheet:

 UIActionSheet *DeleteAction = [[UIActionSheet alloc] initWithTitle:@"Select    Delete Option" delegate:self cancelButtonTitle:Nil destructiveButtonTitle:nil   otherButtonTitles:nil, nil];
[DeleteAction addButtonWithTitle:@"A"];
[DeleteAction addButtonWithTitle:@"B"];
[DeleteAction showInView:self.view];

And I'm using this delegate for action sheet

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
if ([actionSheet buttonTitleAtIndex:buttonIndex] == @"A") {....}
if ([actionSheet buttonTitleAtIndex:buttonIndex] == @"B") {....}
}

Upvotes: 3

Views: 829

Answers (2)

Amitabha
Amitabha

Reputation: 1662

problem solved .

 if ([[actionSheet buttonTitleAtIndex:buttonIndex]isEqualToString: @"A"]) {....}

this worked for me.

Upvotes: 2

sri
sri

Reputation: 227

I have used this code and working fine . Let me know Is it showing the Actionsheet or not

-(void)share {
    UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:@"" delegate:self cancelButtonTitle:@"cancel" destructiveButtonTitle:nil otherButtonTitles:@"Email this Info",@"Tweet this Info",@"Share On Facebook", nil];
    popupQuery.actionSheetStyle = UIActionSheetStyleBlackOpaque;
    [popupQuery showInView:self.view];
    [popupQuery release];
}

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (buttonIndex == 0) {
        [self emailinfo];
    } 
    if (buttonIndex == 1) {
        [self tweetinfo];
    }
    if (buttonIndex == 2) {
        [self shareonfacebook];
    }
    if (buttonIndex == 3) {

    }
}

Upvotes: 2

Related Questions