iOS5: UIWebView doesn’t display Gmail after some attachment files were opened - uiwebview

Is there any fix/workaround for the problem?
Summary:
On iOS5 devices/simulators, applications with UIWebView do not display Gmail after some kinds of attachment files were opened, such as .pdf, .txt, or .xml. I build some simple apps with UIWebView, which have the searchBar, the goBack button and so on. They work perfectly on iPhone 4.3 devices/simulators when they are built for iOS 4.3, but they do not on those of 5.0. The projects built for iOS5 also have the same problems.
Steps to Reproduce:
Build an app targeted for iOS 4.3 or 5.0 with UIWebView, which has at least a goBack button and a searchBar for URLs.
Run the app on an iOS5 device / simulator.
Log in to Gmail in the app.
Open a pdf (txt / xml) attachment of one of your emails.
(This problem does not happen when you open a Microsoft office file supported by UIWebView, such as word, excel and powerpoint.)
Go back to the previous page by pushing the goBack button, or enter the URL “http://mail.google.com” in the searchBar.
The UIWebView shows a white blank.
After that you can never see your Gmail page.
Expected Results:
You can go back to the previous email (when you push the goBack button), or go to the top of Gmail page (when you enter the Gmail URL).
Actual Results:
The UIWebView just shows a white blank, and never let you see any Gmail page.
Regression:
Occur:
- iOS Deployment Target 4.3, run on iOS 5.0 devices / simulators
- iOS Deployment Target 5.0, run on iOS 5.0 devices / simulators
Does Not Occur:
- iOS Deployment Target 4.3, run on iOS 4.3 devices / simulators
Thanks

I had the same problem but could not fix it. I suggest you one of the workaround.
If your UIWebView goes to "mail-attachment.googleusercontent.com" , the Go back
action is wrong. So when the URL is detected, you had better create another view and load the attachment on it. The second has the GO back button however when it is pushed down you discard the second view then return to the first view via IBAction method. It works on iOS4 and iOS5.
my sample code is following.
-(BOOL) firstView:(UIWebView *)view
shouldStartLoadWithRequest:(NSURLRequest *)req
navigationType:(UIWebViewNavigationType)nType{
NSString *strurl=[[[req URL] standardizedURL] absoluteString];
NSRange range=[strurl rangeOfString: #"mail-attachment" options:NSCaseInsensitiveSearch];
if (range.location!=NSNotFound){
Your2ndViewController *attView = [[Your2ndViewController alloc] initWithNibName:#"YourNibNameofAnothor" bundle:nil];
if(attView==nil){
return NO;
}
attView.wvc=self;//mark the first on the second to return the first one
[attView loadURLWithString:strurl];
[self.view addSubview:attView.view ];
[UIView commitAnimations];
[attView loadURLWithString:strurl];
return NO;//Not Load on the first view
}
return YES;//Load on the first view
}
Your 2nd View which is also UIWebView has a return button and it's handler is following
- (IBAction) returnParent:(id)sender
{
[self.view removeFromSuperview];//return to the first view
[UIView commitAnimations];
}

Related

Dismiss UIAlertView programmatically in Xamarin.iOS

I am stuck in a weird scenario where I need to programmatically dismiss the active UIAlertView from the other viewcontroller by getting the instance.
Actually, I am working on AutoClose feature (working on System.Timer) where when Timer would be elapsed, I need to perform some operation (performs in View Model) and close the active UIAlertView or UIViewController window and Navigate To HomeView.
I am able to do with UIViewController but I couldn't find any way to dismiss the UIAlertView which is presented from another view controller?
Note - I understand this API is deprecated but for using UIAlertController it would lead to ample code changes, and I don't have time to make them.
I am using below method to accomplish but once the AlertView gets dismissed I am unable to click anywhere on screen.
UIWindow window = UIApplication.SharedApplication.KeyWindow;
UIViewController rootViewController=window.RootViewController;
if(rootViewController.ModalViewController is UIAlertController)
{
rootViewController.ModalViewController.DismissViewController(true,null);
}
Also, may I know how do we see the hierarchy of Views in Xamarin Studio?
Try to use the following code:
UIAlertView alertView = new UIAlertView("Title", "Content",this,"OK");
alertView.Show();
UIActivityIndicatorView indicatorView = new UIActivityIndicatorView();
indicatorView.BackgroundColor = UIColor.Red;
indicatorView.Center = new CGPoint(alertView.Bounds.Size.Width / 2,
alertView.Bounds.Size.Height - 40.0);
indicatorView.StartAnimating();
alertView.InsertSubview(indicatorView,0);
And if when you want to Dissmiss the AlertView(for emample in the following code I dissmiss it after 3 seconds):
NSTimer.CreateScheduledTimer(3, (t) =>
{
alertView.DismissWithClickedButtonIndex(0, true);
});
I have asked the same question in Xamarin Forum and I got my answer from one of the Xamarin Professional which I am sharing here.
Dismiss UIAlertView programmatically in Xamarin.iOS
I hope this may help others.

Error on TextView with detection phone number IOS 9

I'm testing my app on an iPod Touch running iOS 9 (on iOS 8.4 it was working for other functions: FaceTime, copy to contacts, etc.). I have a textview with phone number detection and I receive the following error:
Warning: Attempt to present <_UIRotatingAlertController: 0x16250e00> on whose view is not in the window hierarchy!
Assertion failure in -[UITextView startInteractionWithLinkAtPoint:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3505.16/UITextView_LinkInteraction.m:377
Any fix to this?
Not a perfect solution but very simple and may help a desperate developer:
- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange {
[[UIApplication sharedApplication] openURL:URL];
return NO;
}
You will lose the Copy, Open URL, Cancel popover on long press but you SHOULD at least be able to open url same as you would previously. In iOS 9, this still opens a browser window inside your app for standard URLs (which is nice).
This seems like an Apple bug (posted to radar already).
We were seeing very similar error when trying to open links in a modal view since Apple is trying to display a new modal alert view. Outside of modal view data detection worked just fine in iOS 9 for us.
This looks quite similar to a bug we recently had to fix for PSPDFKit where presenting sheets did not work when the rootViewController was already presenting another controller. (Is your rootViewController maybe not set?)
You can read the source code here. This might help you to figure out where the issue is for you:
https://gist.github.com/steipete/b00fc02aa9f1c66c11d0f996b1ba1265
And please dupe rdar://26295020 so this will get hopefully fixed in time for iOS 10. (The bug exists since iOS 8 and was first reported on iOS 8b5.)

Setting background to GroupTableViewBackgroundColor

I have a UIViewController in my Monotouch iPhone application and I want to set the background to what you have in a UITableViewStyle.Grouped. However when I use the code below it returns a black screen.
this.View.BackgroundColor = UIColor.GroupTableViewBackgroundColor; // Black screen
this.View.BackgroundColor = UIColor.Red; // Works
I call these in the ViewWillAppear method. If I comment out the GroupTable then the background gets set to Red. When I comment out the second line all I get is a black screen.
Does anyone know why this is? Can you not call UIColor.GroupTableViewBackgroundColor if your not in a UITableViewController?
Thanks
Mike
i have used this on my current project & it works fine i have xcode 4.0 & simulator 4.3
i have found on net that it is deprecated on ios 6
i have used like this
[self.tableview setBackgroundColor:[UIColor groupTableViewBackgroundColor]];
just have look at this link is groupTableViewBackgroundColor deprecated on iOS 6?
for alternative you can find out same image as UItableview Grouped style background on internet.

UISplitViewController problems with IOS 5.1

I have a problem,
I am programming with Monotouch 5.2.8 for IOS 5.1.
But since the IOS 5.1 update my iPad configs the UISplitViewController so it is docked on the
left side instead of presented as a popover.
It works with IOS 5.0 but in 5.1 i got this problem.
Here is the source code for my UISplitViewController:
splitViewController = new UISplitViewController ();
splitViewController.WeakDelegate = detailViewController;
splitViewController.ViewControllers = new UIViewController[] {
navigationController,
detailViewController
};
From Apple's iOS 5.1 SDK release notes:
In 5.1 the UISplitViewController class adopts the sliding presentation
style when presenting the left view (previously only seen in Mail).
This style is used when presentation is initiated either by the
existing bar button item provided by the delegate methods or by a
swipe gesture within the right view. No additional API adoption is
required to obtain this behavior, and all existing API, including that
of the UIPopoverController instance provided by the delegate, will
continue to work as before. If the gesture cannot be supported in your
app, set the presentsWithGesture property of your split view
controller to NO to disable the gesture. However, disabling the
gesture is discouraged because its use preserves a consistent user
experience across all applications.
Here (login required).
UPDATE:
From what I understand on the above, we can kiss the automatic popover appearance of the master controller goodbye in iOS 5.1.
The only way I see is possible to keep the "old" appearance, is by implementing our own UIPopoverController and taking advantage of the ShouldHideViewController delegate method. Thankfully with MonoTouch, we have that method available as a property in the UISplitViewController class, making things a bit simpler.
I do get a strange behavior though. With iOS SDK 5.1 on my Mac and iOS 5.1 on my iPad; on the device, I get the "sliding" appearance, while on the simulator I get the "old", popover appearance. This is with MonoTouch 5.2.4, which is the latest stable version. Also, it does not contain a PresentsWithGesture property. I tried setting its value to false through MonoTouch.ObjCRuntime messaging, but no luck. The selector keeps returning true. So I cannot deactivate the swipe gesture.
Even tried creating my own UIPopoverController and assigning it as the master in the split controller to see what happens. Doesn't work because UIPopoverController is not a UIViewController...
Some useful info in this question, for ObjC.
Turns out you can disable the presentsWithGesture in the application delegate, but once the view controllers have been presented, there is no changing it.
I needed to disable the appearance of the left view controller during a login process, but turns out I can't enable it later.

Simple UIWebView

I'm making a tab bar app and one of the tabs is a youtube channel. It works fine and is perfect but the one problem is when i click on the video it plays but only in the standard view and not in Landscape. Any ideas on how to fix. Im sure its really simple but i've been having no luck.
This question probably answers what you are trying to do:
Webview resizes automatically to portrait and landscape view in iphone
The key thing to take away from it is that you need your view controller to tell the app that it supports the other orientations, not just portait.
- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) orientation
{
return YES;
}

Resources