UIProgressView+Activity Indicator View on a UITableView during data upload - objective-c

I have a uitableview.
I saw this "effect" and I would replay it:
When the user taps on a button to upload some data on a server, I would a gray (transparent) view with a progress bar (maybe with also an activity indicator) appears on the table.
The table is disabled and can be viewed through the gray view (that is the gray transparent view covers all the table).
How can I achieve this?
Have I create a view with a progressive view on it and then put it in the same xib of the table, disabling it properly programmatically? Or?

Lay a large black UIView over top of the UITableView with an alpha value of 0.5. Then put a spinner (UIActivityIndicatorView) on top of that.
Something like this:
UIView *view = [[UIView alloc] init];
view.frame = myTableView.frame;
// save this view somewhere
UIActivityIndicatorView *ac = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
CGRect frame = view.frame;
ac.center = CGPointMake(frame.size.width/2, frame.size.height/2);
[view addSubview:ac];
[ac startAnimating];
[ac release];
[myTableView addSubview:view];
[view release];
Then remove it later with [view removeFromSuperview]

Related

how to pop a drawing uiview as a model view only half of the screen

I create new viewcontroller class with xib then created uiview inherited class and in xib file custom class I wrote the uiview inherited class name(PaintView).
I am trying to implement a simple drawing feature in my app, I created a simple drawing code which paints on uiview using touchbegain, thouchmoves, drawrect methods in PaintView class.
Till here its all working fine now I want to pop a model of this view, but I want it to display half of the screen, I resize it in interface builder but it is still showing on full screen.
Other posts says create a transparent view add contents at bottom half thats how you will get half model view, but this is not a solution for my problem.
How to properly pop model view but only half of the screen.
Simple, don't present it modally.
UIViewController *controller = [[UIViewController alloc] initWithNibName:#"myXib" bundle:[NSBundle mainBundle]];
[controller.view setFrame:CGRectMake(0, 480, 320, 320)];
[self.view addSubview:controller.view];
[UIView animateWithDuration:0.5 animations:^{
[controller.view setTransform:CGAffineTransformMakeTranslation(0, -320)];
}];
To change the color's I recommend you store the integer values of your color's hues into an array, that way you can stably assign the hue from the integer value of some object in the array:
arrayOfColors = [[NSArray alloc] initWithObjects:#"0.0", #"0.1", #"0.2", #"0.3", #"0.4", #"0.5", #"0.6", #"0.7", #"0.8", #"0.9", nil];
[[UIColor colorWithHue:[[arrayOfColors objectAtIndex:someIndex]floatValue] saturation:1.0 brightness:1.0 alpha:1.0]setStroke];

How to make detail view scrollable in master detail app

I have only been working in iOS for a few months but I have been banging my head against the wall for hours and hours for something that seems like it should be pretty straightforward. I used the master detail template in Xcode for an iPad app. I want the detail portion to be scrollable to show content below what is visible in the frame, in either orientation. I have tried numerous combinations of adding scrollviews in the DetailViewController in viewWillAppear, viewDidLoad, loadView...and the best I can come up with is what looks like a scrollable view on the top layer as it does show scroll bars and shows me that I did the scrollView.contentSize correctly as I can pan around, but the actual view with the fields and stuff doesn't move and the fields are unable to be edited. Here is my viewDidAppear as it stands at the moment. As you can see in the NSLogs I am trying to understand the view stack. If I uncomment the line before the logs, I lose the scroll bars altogether.
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 768, 1024)];
scrollView.contentSize = CGSizeMake(2048, 2048);
UIView *parentView = [[UIView alloc] init];
parentView = [[self view] superview];
[[parentView superview] addSubview:scrollView];
//[scrollView addSubview:[self view]];
NSLog(#"%#", [parentView superview]);
NSLog(#"%#", parentView);
NSLog(#"%#", [super view]);
NSLog(#"%#", [self view]);
[scrollView setDelegate:self];
}
I would sincerely appreciate any guidance or tips on how to properly implement UIScrollView for this scenario.
You should add the UIScrollView in IB. Be sure to move all of your existing views and controls to be subviews of the scroll view. And you'll have to link the scroll view to an IBOutlet so you can set the content size in your view controller.
Instead of trying to wrap a uiscrollview around your main view's superview (which you have incorrectly tried to take ownership of (it should be NULL anyways)), why not herd your UI elements into a full-sized subview and wrap the scrollview around that? It would be much much easier.
Your hierarchy would look like this:
Self.view -> ScrollView (with contentSize set) -> UIView containing elements that need to be scrolled -> various UI elements

In Cocoa-Touch Framework, is there any modal view in iPad like this?

Is there any model view like this on the iPad?
Yes, there is:
UIModalPresentationFormSheet
The width and height of the presented view are smaller than those of the screen and the view is centered on the screen. If the device is in a landscape orientation and the keyboard is visible, the position of the view is adjusted upward so that the view remains visible. All uncovered areas are dimmed to prevent the user from interacting with them.
For example:
UIViewController *viewController = [[UIViewController alloc] init];
viewController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:viewController animated:YES];
viewController.view.superview.frame = CGRectMake(0, 0, 540, 500); // this is important to do this after presentModalView
viewController.view.superview.center = self.view.superview.center;

UINavigationBar with customized background - how to make rightBarButton visible

I've customized background of navigation bar in my RootViewController (just part of code)
[navBar insertSubview:customBack atIndex:0];
I push detailViewController and add activity indicator as a rightBarButtonItem
UIActivityIndicatorView *actInd = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
actInd.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
self.activityIndicator = actInd;
[actInd release];
UIBarButtonItem * barButton = [[UIBarButtonItem alloc] initWithCustomView:self.activityIndicator];
[self.navigationItem setRightBarButtonItem:barButton];
[barButton release];
The problem is that the indicator is not visible but without customized background it works OK.
You can better change your navigationBar Background I think. Create a subclass of UINavigationBar and add:
- (void)drawRect:(CGRect)rect {
UIImage * image = [UIImage imageNamed:#"MyNavigationBarBackground.png"];
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextScaleCTM(ctx, 1.0, -1.0); // Otherwise the image is drawn upside-down
CGContextDrawTiledImage(ctx, CGRectMake(0, 0, image.size.width, image.size.height), image.CGImage);
}
I do that and I never add a problem with any button :)
Zoleas has the right idea. If you don't or can't use a subclass, I think your problem is that you are adding your subview at index 0 so it is on top of the other views in the navigation bar, it is probably hiding your buttons.
set rightBarButtonItem with following way
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:#"Exit" style:UIBarButtonItemStylePlain target:self action:#selector(cancel)];
Try this and also check the position of background
The activity indicator is there its just not being activated. Try animating it like this:
[actInd startAnimating];
Or if you want to keep it visible set the hideWhenStopped property like this:
actInd.hidesWhenStopped = NO;
Did you try to change the origin from the UIActivityIndicatorView?
Or creating it inside an UIView and add this UIView to the UIBarButtonItem.
I think the problem can be the frame from the element.
By this way you can resolve the problem:
Create activity indicator and add in a view1
Now this view1 add or create navigation bar with the help of this view1. Now when view1 is visible automatically you will be able to see the loading indicator.
Just wild try on this.

NSTextView fails when used as contentView

I am programmatically creating a NSTextView to be the contentView for a window. When I create a WebView using the following code, it displays scrollbars, and the resizing thumb, and resizing the window works flawlessly.
When I comment out the WebView and attempt to use a NSTextView as the contentView, it does not "work" when the window is resized: Resizing the window using the thumb causes the content of the text view to not repaint correctly, it also paints over the title of the window, and the resizing thumb is also not repainted.
-(void)applicationDidFinishLaunching:(NSNotification*)aNotification{
NSTextView* view = [[NSTextView alloc] initWithFrame:[window frame]];
// WebView* view = [[WebView alloc] initWithFrame:[window frame]];
[window setContentView:view];
[window makeFirstResponder:view];
[window makeKeyAndOrderFront:view];
}
Edit: Working code. Creates a NSScrollView to be the windows new contentView, and adds an NSTextView as its document.
-(void)applicationDidFinishLaunching:(NSNotification*)aNotification{
NSScrollView* scrollView = [[NSScrollView alloc] initWithFrame:[window frame]];
NSTextView* view = [[NSTextView alloc] initWithFrame:[scrollView bounds]];
[window setContentView:scrollView];
[scrollView setDocumentView:view];
[scrollView setHasVerticalScroller:YES];
[scrollView setHasHorizontalScroller:YES];
[window makeFirstResponder:view];
[window makeKeyAndOrderFront:view];
}
A web view makes and manages its own scrollers and is a special case rather than the norm. An NSTextView does not. It's just the text view. This is the norm - scrollable views come pre-wrapped in an NSScrollView only in the convenience of Interface Builder. In code, you must create an NSScrollView as well, then wrap the view in it. It's the scroll view that would be your top-level view in that case.