How to use UIAlertController to replace UIActionSheet?

前端 未结 6 1385
醉话见心
醉话见心 2020-12-13 23:29

I am maintaining an old iOS project which based on SDK 6.0.

A method on this project called

-(void) showComboBox:(UIView*)view:withOptions:(NSDictiona

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-13 23:49

    I have used action sheet for changing profile picture. I followed Kampai approach, just removed dismissviewController call since it was kicking me out of a view when pressing Cancel or photo selection view

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
    
    [actionSheet addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
    
        // Cancel button tappped do nothing.
    
    }]];
    
    [actionSheet addAction:[UIAlertAction actionWithTitle:@"Take photo" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
    
        // take photo button tapped.
        [self takePhoto];
    
    }]];
    
    [actionSheet addAction:[UIAlertAction actionWithTitle:@"Choose photo" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
    
        // choose photo button tapped.
        [self choosePhoto];
    
    }]];
    
    [actionSheet addAction:[UIAlertAction actionWithTitle:@"Delete Photo" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
    
        // Distructive button tapped.
        [self deletePhoto];
    
    }]];
    

提交回复
热议问题