Need advise about loading screen on iPhone - iphone

could you show me some algorithm or example code to display like that picture with or with out animation
thanks for all advise

Add a semi-transparent view (regular view with black background with opacity = 80) that will cover the entire screen (in IB or in code), add a UIActivityIndicator and a label to the semi-transparent view, set it hidden.
If you use the IB then you should also create IBOutlets for the semi-transparent view (loadingView) and for the activity indicator (loadingAnimationIndicator)...
Use the next methods to show / hide the "loading view":
- (void)showLoading {
[loadingAnimationIndicator startAnimating];
loadingView.hidden = NO;
}
- (void)hideLoading {
loadingView.hidden = YES;
[loadingAnimationIndicator stopAnimating];
}

Related

Hide and show a view

I have small view with a UITextField in it. I want to make the view hidden by default. when a button clicked it should show the view and the elements in main view below this sub view must be scrolled down. Any idea? I'm attaching the screenshots
Set the UITextView as hidden from InterfaceBuilder (you can set it from code too).
After this attach this action handler to the UIButton.
- (IBAction)showTextBar
{
[textView setHidden:False];
return;
}
This will show the textBar. If you want to show some other elements then you can add them in this method. Also you can make this method like a toggle. click once to show the elements, click again to hide them.
Inside the action u can also use
textView.hidden = NO;
As for the scrolling use a UIScrollView something like
[_scrollView setContentOffset:CGPointMake(0,_textView.center.y+168) animated:YES];
//Alternate between hide and show when button is clicked
-(IBAction)showTextBar
{
if(textview.hidden)
{
[textView setHidden:False];
}
else
{
[textView setHidden:True];
}
}

Black bar appearing in UIWebview when device orientation changes

I have a UIWebView that I am loading onto another view, everthing looks fine in portrait or landscape when rotating, however when I am in portrait and I zoom in slightly with pinch or double tap when I rotate from portrait to landscape the view dosnt fill completely with the uiwebview, there are about 10pxls on the right that turn black as outlined in this screen shot.
if you look carefully you can see the outline of the scroll indicator in the black, which segests this is part of the uiwebview?? if so then why dose it turn black in this area.
Also heres another screen shot of the webview scrolled up abit so you can see its part of the uiwebview...
This is how I am adding the view onto the detail view.
- (void)viewdidload
//..
//Load in FirstView
firstView = [[FirstMainViewController alloc] init];
firstView.view.frame = CGRectMake(0.0, 0.0, firstView.view.bounds.size.width, firstView.view.bounds.size.height);
firstView.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
firstView.view.backgroundColor = [UIColor whiteColor];
[self.view insertSubview:firstView.view belowSubview:actionTabBar];
//..
Try to set the background of the webView transparent (clearColor) and set it's opaque property to FALSE. Then make the background white in your html or simply have the view beneath the webView white.
I had the same problem, and simply setting opaque to NO fixed it. Didn't even have to change the background color, it works fine with the background color set to white.
I put in the line...
webView.scrollView.backgroundColor = UIColor.whiteColor()
webView is my #IBOutlet weak var webView: UIWebView!
Turn off WebKitDiskImageCacheEnabled and the black border goes away :
In applicationDidFinishLaunchingWithOptions add the following lines :
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:#"WebKitDiskImageCacheEnabled"];
[[NSUserDefaults standardUserDefaults] synchronize];

Why does my view become white when i remove a subview?

in my view I have a scrollView as subview. The scrollView has another subview called thePDFView. It is for showing a PDF page.
This view has 2 subviews. drawImage is an image loaded from disk above the whole PDF view.
And paintView is the second subview where all the painting and markup is done.
But I only want to add paintView when I press the paint Button.
This works, but when I press it again to stop painting mode and remove the view from superview, the whole screen gets white.
How can I bypass that?
- (id)init
{
...
[self.view addSubview:theScrollView];
[theScrollView addSubview:thePDFView];
drawImage = [UIImage imageWithData:retrievedData];
[thePDFView addSubview:drawImage];
paintView = [[PaintViewController alloc] initWithImage:drawImage andPath:pageString];
}
- (void) togglePainting:(NSNotification *)notif {
if (!painting) {
theScrollView.scrollEnabled = false;
[thePDFView addSubview:paintView.view];
}
else {
theScrollView.scrollEnabled = true;
[thePDFView removeFromSuperview];
}
painting = !painting;
}
[thePDFView removeFromSuperview];
removes the whole view which was inside the scroll view leaving you nothing but the scrollview which does not have any subviews now. Hence your view is white. I think you wanted to remove only paintView.view so it should be [paintView.view removeFromSuperview];

UIView should be transparent but only shows white

I have a UIViewController which contains a label and button. I would like the background of the view to be transparent so I set it to clearColor and opaque = NO.
However, the view always displays a white background. How can I fix this?
Thanks.
Once a new view controller is pushed to the top of the stack, whatever is behind it gets hidden so you can adjust the alpha settings for that view but there's nothing to reveal behind it (so you will see white).
You need to use a UIView instead. I'd normally subclass UIView and customise it the way I want, then instantiate and add it as a subview whenever you need to use it:
-(id)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:CGRectZero])
{
// Add your label and button here...
}
return self;
}
Sorry, I do not have enough rep to comment on Rog's answer, so I will post 'Another Answer'.
Try this code and see if it turns out well for you:
UIVIew *view = [[UIView alloc] init];
view.alpha = 0; // alpha 1.0 is opaque, alpha 0.5 is translucent and 0 is clear
Honestly, I have not tried that before as I do not require doing so. But when I drag a new UIView from the library, alpha option is in the properties.
Hope this helps.

Resizing UINavigationBar on rotation

I have a subclass of UIViewController which handles a UIView. The viewcontroller is presented modally (it slides up from the bottom of the screen). At the top of the view, i have added a navigation bar. Note that this bar is not handled by a navigation controller.
I want to get the navbar to shrink in height when the view rotates to landscape (similar to how it behaves when it is handled by a UINavigationController). However, I can't set its autoresizing mask to flexible height in IB, and doing so in code causes the navbar to disappear completely.
Is there a way to do this? How is it done by the UINavigationController?
P.S. I would prefer not having to resort to a scaling transform, since this would mess up the text in the title.
EDIT: I solved it with a little help, read the answer posted below.
Rather than set it's autoresizing mask, why don't you just check the current orientation in viewWillAppear, as well as in didRotateFromInterfaceOrientation, and set the appropriate frame?
- (void) updateNavBar {
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if ((UIInterfaceOrientationLandscapeLeft == orientation) ||
(UIInterfaceOrientationLandscapeRight == orientation)) {
myNavBar.frame = CGRectMake(0, 0, 480, 34);
} else {
myNavBar.frame = CGRectMake(0, 0, 320, 44);
}
}
- (void) viewWillAppear {
[self updateNavBar];
// ... SNIP ...
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[self updateNavBar];
// ... SNIP ...
}
I found the solution, and in hindsight i feel rather stupid. I just had to include flexible bottom margin in the navbar's autoresize mask. Credit is due to user RayNewbie in this thread, which pointed me to the solution:
http://discussions.apple.com/thread.jspa?messageID=8295525