I need to upload a local picture in my webview (IOS).
Apparently, it seems that Apple has some problems with that.
2016-04-06 18:47:37.337 DemoWebView[839:112324] Warning: Attempt to present on whose view is not in the window hierarchy!
(iOS 8 SDK: modal UIWebView and camera/image picker)
Despite my extensive research, I didn't find a solution to my problem.
if anyone can help me .. I would be very grateful.
class : ViewController
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[button setFrame:CGRectMake(80, 150, 160, 60)];
button.backgroundColor = [UIColor whiteColor];
[button setTitle:@"Click Here !" forState:UIControlStateNormal];
[self.view addSubview:button];
}
-(void) buttonClicked:(UIButton*)sender{
ViewController2 * test = [[ViewController2 alloc]init];
[self presentViewController:test animated:true completion:NULL];
}
@end
class : ViewController2
@interface ViewController2 : UIViewController
@end
#import "ViewController2.h"
@interface ViewController2 ()
@property (strong, nonatomic) UIWebView *webView;
@end
@implementation ViewController2
- (void)viewDidLoad {
[super viewDidLoad];
_webView = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.view = _webView;
[_webView loadHTMLString:@"<br /><br /><input type=\"file\" accept=\"image/*;capture=camera\">" baseURL:nil];
}
@end
DemoProjet :
Thks