subview

How to add a Container View programmatically

一个人想着一个人 提交于 2019-11-26 23:45:41
A Container View can be easily added into a storyboard through Interface Editor. When added, a Container View is of a placeholder view, an embed segue, and a (child) view controller. However, I am not able to find a way to add a Container View programmatically. Actually, I am not even able to find a class named UIContainerView or so. A name for the class of Container View is surely a good start. A complete guide including the segue will be much appreciated. I am aware of View Controller Programming Guide, but I do not regard it as the same as the way Interface Builder does for Container Viewer

Cannot put a google maps GMSMapView in a subview of main main view?

独自空忆成欢 提交于 2019-11-26 21:59:10
I'm struggling with this problem! I want to add a google maps GMSMapView into a UIView that is only a portion of the main UIView of my ViewController . It should be simple... I created with the storyboard a UIView of the size I want and put it in the main UIView . Snippet from Interface file: @interface MapViewController : UIViewController <CLLocationManagerDelegate> @property(nonatomic) IBOutlet GMSMapView *mapView; With the mapView linked with this UIView inside the main UIView . What I do in the implementation: @synthesize mapView = _mapView; - (void)viewDidLoad { [super viewDidLoad]; // Do

Apple Interface Builder: adding subview to UIImageView

a 夏天 提交于 2019-11-26 21:58:06
I created UIImageView with the help of Interface Bulder. Now I want to place label inside it (as its subview). In code I can type something like: [myUIImageView addSubview:myUILabel]; But can I do it with the help of IB? I found the solution for UIView , but can't find something similar for UIImageView . You cannot add a subview to UIImageView in interface builder for reasons only known to Apple! You are right in saying that you can addSubview programmatically, but then, the overhead of setting autoresizing masks and placements of subviews should all be handled in code, which is cumbersome. So

Remove all subviews?

流过昼夜 提交于 2019-11-26 21:08:15
When my app gets back to its root view controller, in the viewDidAppear: method I need to remove all subviews. How can I do this? e.James Edit: With thanks to cocoafan : This situation is muddled up by the fact that NSView and UIView handle things differently. For NSView (desktop Mac development only), you can simply use the following: [someNSView setSubviews:[NSArray array]]; For UIView (iOS development only), you can safely use makeObjectsPerformSelector: because the subviews property will return a copy of the array of subviews: [[someUIView subviews] makeObjectsPerformSelector:@selector

Adding a UINavigationController as a subview of UIView

喜夏-厌秋 提交于 2019-11-26 20:57:00
问题 I'm trying to display a UILabel on top of a UINavigationController. The problem is that when I add the UILabel as a subview of UIWindow it will not automatically rotate since it is not a subview of UIViewController (UIViewController automatically handles updating subviews during rotations). This is the hierarchy I was using: UIWindow UILabel UINavigationController So I was thinking I could use the following hierarchy: UIWindow UIViewController UIView UILabel UINavigationController This way

UISegmentedControl Best Practice

为君一笑 提交于 2019-11-26 18:59:39
问题 I'm trying to work out the "best" way to use a UISegmentedControl for an iPhone application. I've read a few posts here on stackoverflow and seen a few people's ideas, but I can't quite sort out the best way to do this. The posts I'm referring to are: Changing Views from UISegmentedControl and How do I use a UISegmentedControl to switch views? It would seem that the options are: Add each of the views in IB and lay them out on top of each other then show/hide them Create each of the subviews

Defining child views without an initialize method

会有一股神秘感。 提交于 2019-11-26 17:19:17
问题 I have a large number of views (more than 50) which all extend from a single abstract base view, and therefore have a similar layout and many other features in common (event handlers, some custom methods and properties, etc). I am presently using the initialize method of my base view to define the layout, which involves a subview, somewhat like the following: App.BaseView = Backbone.View.extend({ //... initialize: function() { this.subView = new App.SubView(); }, render: function() { this.$el

How can I loop through all subviews of a UIView, and their subviews and their subviews

Deadly 提交于 2019-11-26 15:49:48
How can I loop through all subviews of a UIView, and their subviews and their subviews? Use recursion: // UIView+HierarchyLogging.h @interface UIView (ViewHierarchyLogging) - (void)logViewHierarchy; @end // UIView+HierarchyLogging.m @implementation UIView (ViewHierarchyLogging) - (void)logViewHierarchy { NSLog(@"%@", self); for (UIView *subview in self.subviews) { [subview logViewHierarchy]; } } @end // In your implementation [myView logViewHierarchy]; RamaKrishna Chunduri Well here is my solution using recursion and a wrapper(category/extension) for the UIView class. // UIView+viewRecursion.h

add UIImage in CALayer

余生长醉 提交于 2019-11-26 15:15:26
问题 I must add a UIImageView as subview of MapView. To do this I created a layer above the MapView. In this layer I want to put my image, but I get a white rectangle and nothing else. My image is not visible. This is the code: - (void)viewDidLoad { //...... CALayer *layer = [CALayer layer]; layer.backgroundColor = [[UIColor whiteColor] CGColor]; if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { layer.bounds = CGRectMake(self.mapView.bounds.origin.x, self.mapView.bounds.origin.y, 80,

When to use f:view and f:subview

风流意气都作罢 提交于 2019-11-26 12:00:24
问题 I am not sure what are the benefits of using <f:view> and <f:subview> . I noticed that one could write JSF pages without using them. What are the benefits of using those tags? 回答1: <f:view> The <f:view> is only useful if you want to explicitly specify/override any of the available attributes such as locale , encoding , contentType , etc or want to attach some phase listeners. E.g. <f:view locale="#{user.locale}" encoding="UTF-8" contentType="text/html"> If you don't specify it, then the sane