Saturday, 16 February 2013

Action Sheet with delegate


-(void)add_an_Image
{
    
    actionSheet_OpenImages=[[UIActionSheet alloc]initWithTitle:@"Select Image Source" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Open Library",@"Camera", nil];
    [actionSheet_OpenImages setActionSheetStyle:UIActionSheetStyleBlackOpaque];
    [actionSheet_OpenImages showInView:self.view];
}





#pragma mark actionSheet delegate
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    actionSheet_OpenImages.hidden=YES;
    
    switch (buttonIndex) {
         case 0:
            [self Open_Library];
            break;
        case 1:
            [self Open_Camera];
            break;
            
        default:
           break;
        }
    
    
}