uiview-hierarchy

recursiveDescription method in Swift?

天涯浪子 提交于 2019-11-30 10:24:21
问题 Is there a way to use [self.view recursiveDescription] in Swift? I am trying to use this method but I am getting the following error: 'UIView' does not have a member named 'recursiveDescription' Any suggestions? 回答1: In order to access private / undocumented Objective-C API (like the -recursiveDescription method on UIView ) from Swift you can do the following: Create a new Objective-C category on the class the private method is defined in (e.g. UIView ). Hit Yes if Xcode asks you about

What type of contents UIViewContentMode mode refers to?

邮差的信 提交于 2019-11-30 03:38:45
问题 According to the official doc on UIView about the contentMode property: The content mode specifies how the cached bitmap of the view’s layer is adjusted when the view’s bounds change What's defined the content in this definition? Is it a sub view or when we have define a background color for a view for example. My very first guess was that it should apply at least for the subviews in a view, but for example the following code snippet will not give me the expected result when playing with the

recursiveDescription method in Swift?

倾然丶 夕夏残阳落幕 提交于 2019-11-29 20:17:52
Is there a way to use [self.view recursiveDescription] in Swift? I am trying to use this method but I am getting the following error: 'UIView' does not have a member named 'recursiveDescription' Any suggestions? In order to access private / undocumented Objective-C API (like the -recursiveDescription method on UIView ) from Swift you can do the following: Create a new Objective-C category on the class the private method is defined in (e.g. UIView ). Hit Yes if Xcode asks you about configuring an bridging header. (If you have already an bridging header in your project this step will be skipped)

How to add image with parallax effect above UITableView header and keep header sticky?

时光怂恿深爱的人放手 提交于 2019-11-28 22:59:09
问题 Here is an image that explains everything I want to do: My question is, how would I make my view structure. The header of the table view should be fixed at top of the table. But what about the top most image that is above the table view header. Will I have to add the table view inside the UIScrollView ? Parallax effect can be done by CATransform3D , but how would I achieve what I want, that is my question. There are lots of demos but I want to make it done custom. 回答1: You can add image view

iOS: Warning “attempt to present ViewController whose view is not in the window hierarchy”

巧了我就是萌 提交于 2019-11-28 19:07:30
I am getting following warning when I try to present a ActivityController on navigation controller, Attempt to present <UIActivityViewController: 0x15be1d60> on <UINavigationController: 0x14608e80> whose view is not in the window hierarchy! I have tried to present view controller by following code, UIActivityViewController * activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:applicationActivities]; activityController.excludedActivityTypes = excludeActivities; UIViewController *vc = self.view.window.rootViewController; [vc

iOS: Warning “attempt to present ViewController whose view is not in the window hierarchy”

▼魔方 西西 提交于 2019-11-27 20:28:05
问题 I am getting following warning when I try to present a ActivityController on navigation controller, Attempt to present <UIActivityViewController: 0x15be1d60> on <UINavigationController: 0x14608e80> whose view is not in the window hierarchy! I have tried to present view controller by following code, UIActivityViewController * activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:applicationActivities]; activityController

Centering subview's X in autolayout throws “not prepared for the constraint”

那年仲夏 提交于 2019-11-27 03:35:24
I have a custom UIView subclass which is being initialized via a nib. In -awakeFromNib , I'm creating a subview and attempting to center it in its superview. [self setInteralView: [[UIView alloc] init]]; [[self internalView] addConstraint: [NSLayoutConstraint constraintWithItem: [self internalView] attribute: NSLayoutAttributeCenterX relatedBy: NSLayoutRelationEqual toItem: self attribute: NSLayoutAttributeCenterX multiplier: 1 constant: 0]]; This breaks, and causes the following output: 2013-08-11 17:58:29.628 MyApp[32414:a0b] The view hierarchy is not prepared for the constraint:

How to list out all the subviews in a uiviewcontroller in iOS?

天涯浪子 提交于 2019-11-27 00:01:32
I want to list out all the subviews in a UIViewController . I tried self.view.subviews , but not all of the subviews are listed out, for instance, the subviews in the UITableViewCell are not found. Any idea? You have to recursively iterate the sub views. - (void)listSubviewsOfView:(UIView *)view { // Get the subviews of the view NSArray *subviews = [view subviews]; // Return if there are no subviews if ([subviews count] == 0) return; // COUNT CHECK LINE for (UIView *subview in subviews) { // Do what you want to do with the subview NSLog(@"%@", subview); // List the subviews of subview [self

Centering subview&#39;s X in autolayout throws “not prepared for the constraint”

拟墨画扇 提交于 2019-11-26 10:37:29
问题 I have a custom UIView subclass which is being initialized via a nib. In -awakeFromNib , I\'m creating a subview and attempting to center it in its superview. [self setInteralView: [[UIView alloc] init]]; [[self internalView] addConstraint: [NSLayoutConstraint constraintWithItem: [self internalView] attribute: NSLayoutAttributeCenterX relatedBy: NSLayoutRelationEqual toItem: self attribute: NSLayoutAttributeCenterX multiplier: 1 constant: 0]]; This breaks, and causes the following output:

Capturing touches on a subview outside the frame of its superview using hitTest:withEvent:

北城以北 提交于 2019-11-26 04:34:55
问题 My problem: I have a superview EditView that takes up basically the entire application frame, and a subview MenuView which takes up only the bottom ~20%, and then MenuView contains its own subview ButtonView which actually resides outside of MenuView \'s bounds (something like this: ButtonView.frame.origin.y = -100 ). (note: EditView has other subviews that are not part of MenuView \'s view hierarchy, but may affect the answer.) You probably already know the issue: when ButtonView is within