Get the current UIView's ID objective-c iphone - iphone

How can I get the current UIView's ID so that I can use it later without using an IBOutlet?
I would like to add an image over the top of my app but I'm switching views frequently and would like to be able to add the image to the current view because it would show up in my second view
Thnx in advance.

You can't access a UIView by ID in the way that you can on Android devices. IBOutlets are the equivalent for connecting graphical layouts to code.
Based in your comment, the appropriate thing for you to do is to be adding the overlay view at a higher level in the view hierarchy. If you have two views that could be displayed at any given time, and you want to make sure you can cover either of them regardless of which is in place, add your overlay view to the superview of those two. This works all the way up to using the UIWindow object that your App Delegate has, which will let you overlay on top of everything (this is essentially how UIAlertViews work, for example.)

You could set the UIView's tag attribute. Then you can reference it from the superview with
- (UIView *)viewWithTag:(NSInteger)tag

Related

Swipe Section Page - Swift 3

I want to make the horizontal swipeable page like YouTube. Is there an object in XCode for this? How do I have to do it? I did not find a tutorial about it. Sorry for my English.
Like this
There are tons of components already made for this in the internet, you can try looking at the cocoacontrols site.
If you still want to write your own code for this, one way is writing a custom UIView subclass. The YouTube feature looks very simple and as far as I can guess, they can use two separate UIView subclasses: one for the menu and one for the pages, just as a container.
For the menu you can use UIStackViews or a single UIViews with UIButtons for the page's titles and another view for the selection effect that moves with the UIButton's touch event. This view should provide a delegate or any notification system that fits better to you in order to notify the container that needs to load the right UIViewController's view inside the container.
The container can be a UIView that loads the view property from the UIViewController subclass on demand. Make sure to add the loaded view controller as a child of the parent view controller, otherwise you will loose some important features.
I hope it can help you to start.

UIView code vs interface builder

I have defined a UIView in the header file named rectangle0
I got a question in regards to IB vs coding a view. Please see the following code example:
rectangle0.frame = CGRectMake(0.0, 70.0, 320.0, 190.0);
Now I can re-create the look of the view easy enough in IB except for the coordinates which are greyed out.
So by calling this code in an IBAction after designing the UIView in IB I can display in the app.
[self.view addSubview:rectangle0];
Now the last line of code will call this view to appear at the set coordinates if I code it - but if I build in interface builder I can make it look exactly the same, but it appears from Y coordinate 20 (just under the status bar) and I can't set the coordinate upon calling it - is there a way to do this??
The UIView is being build outside of the ViewController and then linked to it in the connections inspector.
cheers Jeff
I have added an image to show what screen I am using - as you can see the x and y coordinates are greyed out, it would be great if I can set those to something else.
A view inside the NIB is just an object like any other. It is made to be reusable and I believe that is the key point that resulted in the coordinates being greyed out.
Greying out the position makes the developer worry about where is the view going to be placed. I say that because the position is pretty dependent on the container that your view object is going to be added to.
Although it is just my personal opinion and I am looking forward to hearing if there is indeed a way to do that.
You (effectively) said the view is managed by a view controller. Before you can resize the view, you need to change the Size setting in the view controller's Simulated Metrics to "Freeform". (It is probably set to "None" by default.)

Whats the approach to create a view similar to the one at apple app store

I wanted to know how can we design the view controller such that.., the upper half of the screen remains fixed and the below part of the screen can be navigated through.. !!
Should we use slipScreenController here ?
Your description sounds nothing like the Appstore app but the Appstore app simply has one vertical UIScrollView and another horizontal UIScrollView inside that for images.
If you are referring to browsing categories in AppStore then:
That is a tableView implemented in such way that it doesn't take the whole screen area. You need to create a UIViewController (not UITableViewController) and than add a tableView to the view (using Interface Builder or code). That way you can change the size and position of the tableView and use the remaining area of the view for something else, for example a UISegmentedControl above the tableView.
If you are reffering to reading description and images of single app then I think that UIScrollView is used for displaying images, not sure about the rest.

iPhone SDK moving a view and its subviews to back

I have an application with multiple views that contain subviews. I know that you can hide or make visible a view and its subviews by setting the hidden property to YES or NO. However with a number of views, to use the hidden property requires keeping track of what view is being displayed. I thought I could use sendSuBViewToBack: to hide a view and moveSubViewToFront to make it visible. However, these methods appear to only act on the specific subview and not its child subviews. For example, a view with a couple of labels on it, when sent to the back, the labels remain visible.
Is there any way to make this behavior work besides using the hidden property?
Thanks,
Jim
UIViewController seems like what you're looking for. Or rather, what you should be looking for.
I'm not quite sure what exactly you're having trouble with here. As long as you're keeping track of each "container" view (perhaps using a #property), you should be able to show/hide them on demand using a method in your code (which can be as simple as hiding all container views, and then showing the one you desire).

How to display a progress indicator overlay/HUD on iPhone?

I want to display a progress indicator in a semi-transparent box that floats over a table view. In other words, when the table contents are being downloaded, I want an "Updating" label to appear over it.
I have seen this in several apps in the store, notably Facebook (when you shake to reload) and Darkslide.
My first impulse is to create a semi-transparent UIView, place a UILabel and a UIProgressIndicatorView inside it, and add it to the view hierarchy... but where? A UIView may not overlap its siblings, so I can't make it a subview of the window. I also can't make it a subview of the table, because then it will scroll up and down with the table content.
I thought about creating a new UIWindow, but the documentation basically says don't.
I know CALayers can overlap each other, so that would be an option, but I can't put a progress indicator inside a CALayer, can I? Should I roll my own progress indicator that animates a CALayer instead of a UIView?
I'm not interested in hearing about private APIs.
Edit: The question was based on a faulty assumption. NSViews (on Mac OS X) may not overlap, but UIViews on the iPhone may.
I've just posted a HUD version of mine :
https://github.com/y0n3l/LGViewHUD
you can get this result very easily :
#import "LGViewHUD.h"
....
LGViewHUD* hud = [LGViewHUD defaultHUD];
hud.activityIndicatorOn=YES;
hud.topText=#"The longer....";
hud.bottomText=#"The better !";
[hud showInView:self.view];
Once the task is ended, just invoke
[[LGViewHUD defaultHUD] hideWithAnimation:HUDAnimationHideFadeOut];
and that's it !
You can definitely overlap views. Just add the transparent overlay as a subview in the tableView.
From UIView's documentation:
UIView objects are arranged within an UIWindow object, in a nested hierarchy of subviews. Parent objects in the view hierarchy are called superviews, and children are called subviews. A view object claims a rectangular region of its enclosing superview, is responsible for all drawing within that region, and is eligible to receive events occurring in it as well. Sibling views are able to overlap without any issues, allowing complex view placement.
Also there are the quite famous MBProgressHUD & SVProgressHUD
They are the same kind as #yonel 's HUD
Example
[SVProgressHUD show];
[SVProgressHUD dismiss];
MBProgressHUD seems now more popular (if we base on github stars)
Any object that lives in your MainWindow.xib can get access to the application window via an outlet. The application delegate in the standard projects already has it, but you'll probably want to add the outlet to your view controller that needs to show the progress overlay.
Since in UIKit the UIWindow is a UIView (unlike NSWindow vs. NSView in Cocoa), you can simply add your progress view as a subview of the window:
[window addSubview:progressView];
progressView will cover the entire application UI.
This example uses the technique to fade out the Default.png splash image:
http://michael.burford.net/2008/11/fading-defaultpng-when-iphone-app.html
With relation to the recent edit, as of MacOS X 10.5 Leopard NSView overlapping is deterministic (they always could overlap, you just got undetermined results), though it has a different front-to-back ordering depending on whether the containing view is layer backed or not. This is most likely a side effect of integrating CALayers into the OS X view system.
Answer: Apples docs are pretty awesome.
http://developer.apple.com/iphone/library/featuredarticles/ViewControllerPGforiPhoneOS/Introduction/Introduction.html
Currently I'm into over laying transparent views (at least on the back of a napkin at this point). You can use them to hold menu buttons, move them in 3D space, just get nuts.
I mean is this a religious tract of or what? Amazing stuff from the guys at NEXT:
UIView objects are arranged within an UIWindow object, in a nested hierarchy of subviews. Parent objects in the view hierarchy are called superviews, and children are called subviews. A view object claims a rectangular region of its enclosing superview, is responsible for all drawing within that region, and is eligible to receive events occurring in it as well. Sibling views are able to overlap without any issues, allowing complex view placement.