UIImagePickerController within existing UIPopoverController resizing issue on iPad - xcode

I am working on an iPad app where I have a button that generates a popover controller that I am populating with a specific view controller. Here is the button code that generates the UIPopoverController and loads it with a specific view (signUpListAddEditViewController):
-(void)addSignUpList:(id)sender {
signUpListAddEditViewController = [[SignUpListAddEditViewController alloc] init];
popover = [[UIPopoverController alloc] initWithContentViewController:signUpListAddEditViewController];
popover.popoverContentSize = signUpListAddEditViewController.view.frame.size;
[popover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
signUpListAddEditViewController.popover = popover;
}
Inside SignUpListAddEditViewController.m, I have several fields and a tableview. One of the fields is a UIButton where I display an image and allow the user to load a new image using this button. Since I am already in a popover, I swap the content controller with the UIImagePickerController. So far, so good.
-(void)takePicture:(id)sender
{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
[imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[popover setPopoverContentSize:popupScreenSize animated:YES]; // popupScreenSize is a CGSIZE set to 500 x 900
[popover setContentViewController:imagePicker animated:YES];
}
The view is swapped out with the imagePicker with the size remaining the same as the original view and I can see the various picture galleries (Camera Roll, Photo Stream, etc). Here is where it gets strange. As soon as I pick one of the galleries, the view is replaced with a thumbnail view of the pictures in that gallery AND THEN the view resizes to a much narrower width. The images are distorted and nearly impossible to select one of them.
I have tried setting [popover setPopoverContentSize:CGSIZE animated:YES] prior to every access to the popover controller, with everything resizing properly EXCEPT the detailed image view? Any ideas where I can override the thumbnail image gallery view?
Here is the code for the didFinishPickingMediaWithInfo method where I again override the content size:
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
[thisList setThumbnailDataFromImage:image];
[popover setPopoverContentSize:popupScreenSize animated:YES];
[popover setContentViewController:self animated:YES];
listImageButton.imageView.image = image;
}

Related

Presenting UIImagePickerController over modally presented view controller does not work correctly in iOS 8

I have presented UIImagePickerController from modally presented view controller. After clicking the image I get a black image instead of the clicked picture
I did something Like this.
//From ViewController1 I presented view controller2 with
- (IBAction)buttontappedToPresentViewController2:(id)sender
{
ViewController2* controller2 = [[ViewController2 alloc] initWithNibName:#"ViewController2" bundle:nil];
controller2.modalPresentationStyle = UIModalPresentationPageSheet;
[self controller2 animated:YES completion:nil];
}
//In ViewController2, I presented the UIIMagePickerController
- (IBAction)cameraButtonTapped:(id)sender
{
UIImagePickerController *cameraController = [[UIImagePickerController alloc] init];
cameraController.mediaTypes = #[(NSString *)kUTTypeImage,(NSString*)kUTTypeMovie];
cameraController.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:cameraController animated:YES completion:NULL];
}
After clicking the image you will get black screen instead of the captured image with retake and use photo options. If you select "Use Photo" option you get the correct image in callback.
Note: If you do not set UIModalPresentationStyle for viewController2, the code works fine.
Any idea what is going wrong here.
EDIT: I have used XCODE 5.1 and my target deployment is iOS 7. I am running the app on iOS8 device.

Chromium Tabs are reseting flash content in WebView

I'm working with https://github.com/rsms/chromium-tabs in my project and I have created my app so the tabs are registered to a WebView. When I'm debugging I noticed that when I was viewing a Youtube video or any flash content and I switched tabs then switch back the content reloaded or the video restarted. Is there any reason this should hapen.
When a tab is selected it is set: [self becomeFirstResponder];
Other than that I have found no other connected way the flash would reset and the rest of the page would remain the same. I'm believing its a setting in WebView whenever it is not visible.
For the comment bellow:
I followed the examples on Github and used MyTabContents.mm to create the contents. Also used a custom webview.
MyTabContents.mm:
-(id)initWithBaseTabContents:(CTTabContents*)baseContents {
if (!(self = [super initWithBaseTabContents:baseContents])) return nil;
ProgressWebView *wv = [[ProgressWebView alloc] initWithFrame:NSZeroRect];
[wv setProgressDelegate:self];
[[wv mainFrame] loadRequest:[[NSURLRequest alloc] initWithURL:[NSURL URLWithString:#"https://google.com"]]];
[wv setShouldUpdateWhileOffscreen:YES];
webView = wv;
// Create a NSScrollView to which we add the NSTextView
NSScrollView *sv = [[NSScrollView alloc] initWithFrame:NSZeroRect];
[sv setDocumentView:wv];
[sv setHasVerticalScroller:NO];
// Set the NSScrollView as our view
self.view = sv;
return self;
}
AppDelegate.mm:
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
CTBrowserWindowController* windowController =
[[CTBrowserWindowController alloc] initWithBrowser:[MyBrowser browser]];
[windowController.browser addBlankTabInForeground:YES];
[windowController showWindow:self];
}
MyBrowser.mm:
-(CTTabContents*)createBlankTabBasedOn:(CTTabContents*)baseContents {
// Create a new instance of our tab type
MyTabContents *contents = [[MyTabContents alloc]
initWithBaseTabContents:baseContents];
[self changeLayout];
return [contents autorelease];
}

cocoa objective c pdfview not loaded

I am a newbie for MAC development, I have a simple Cocoa Application using NSViewController where I have a main view and 2 NSViewController and dynamically flipping them. I have added PDFView on NSViewController view to show pdf pages flipping at run time. but my problem when the views are added dynamically then on PDFView I can see the pdf page after resizing the window. I tried using [[pdfViewOutlet1 view] setNeedsDisplay:YES]; for both the views.
FirstView *FirstViewController = [[FirstView alloc] initWithNibName:kFirstView bundle:nil];
[FirstViewController setPdfDoc:pdfDoc];
[FirstViewController setPageCnt:pageCnt];
self.myCurrentViewController = FirstViewController;
[[_myCurrentViewController view] setNeedsDisplay:YES];
[transition setSubtype:kCATransitionFromLeft];
[[_myTargetView animator] addSubview: [_myCurrentViewController view]];
and in the awakeFromNib: method of first view I have:
if(pdfDoc==nil )
return;
[pdfViewOutlet1 setDisplayMode: kPDFDisplaySinglePageContinuous]; //kPDFDisplaySinglePage or kPDFDisplayTwoUp;
[pdfViewOutlet1 setDocument:pdfDoc];
NSRect myRect = { { 0,0 }, { 450, 200 } };
[pdfViewOutlet1 setFrame: myRect];
[pdfViewOutlet1 goToPage: [[pdfViewOutlet1 document] pageAtIndex: pageCnt]];
[pdfDoc release];
[[pdfViewOutlet1 view] setNeedsDisplay:YES];
How can I see the pdf pages without resizing the views using mouse?
the issue is solved, i was using setWantsLayer on my Parent view which was creating the issue.

fill UIWebView with local "loading" image before internet content

I have a UITableView with header as a uiwebview (320*44px) for pub content. I wonder how to show some local content image or a background color or whatever before the content get loaded from the web ??
(goal: eleminate the white default background for not-loaded uiwebview banner)
//i assume ur webview object name as webView;
//i assume u were use delegate to ur webview by specifing after creating the webview like
webView.delegate=self;
//dont forget to in .h file #interface urViewController : vijayviewController<UIWebViewDelegate> { <UIWebViewDelegate> is matter.
UIImageView *imageView=[[UIImageView alloc]initWithFrame:webView.bounds];
[imageView setImage:[UIImage imageNamed:#"vijay.png"]];//image size should ur specification 320*44px
[imageView setTag:55];
[webView addSubview:imageView];
[imageView release];
//to remove image
// [[webView viewWithTag:55] removeFromSuperview];
- (void)webViewDidFinishLoad:(UIWebView *)webView{
[[webView viewWithTag:55] removeFromSuperview];
}

Allowing the user to edit a UIImage

I have let the user select an image using UIImagePickerController.
The resulting image is shown in a UIImageView.
There is a UIButton below the image with the title "Edit Image".
My question is, How or to where to i present modal view controller to allow the user to edit the image?
This code allows the user to edit the image s/he has chosen...
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.allowsEditing = YES;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:imagePicker animated:YES];
... but i want the user to be able to edit this image after s/he has picked it as well.
How would i go about doing this?
Perhaps a screen like this:

Resources