superview

Swift find superview of given class with generics

眉间皱痕 提交于 2019-12-22 04:07:20
问题 I guess I'm struggling with generics. I want to create simple UIView extension to find recursively a superview of class passed in the function param. I want the function to return optional containing obviously either nil, or object visible as instance of provided class. extension UIView { func superviewOfClass<T>(ofClass: T.Type) -> T? { var currentView: UIView? = self while currentView != nil { if currentView is T { break } else { currentView = currentView?.superview } } return currentView

UIView touch location coordinates

别等时光非礼了梦想. 提交于 2019-12-22 01:31:49
问题 What are the coordinates used in UIViews and their corresponding superviews? I have this code which i would like to detect a 'corridor' where the user can touch... similar to this image:alt text http://img17.imageshack.us/img17/4416/bildschirmfoto20100721u.png This is the code i have: CGPoint touch = [recognizer locationInView:[shuttle superview]]; CGPoint centre = shuttle.center; int outerRadius = shuttle.bounds.size.width/2; int innerRadius = (shuttle.bounds.size.width/2) - 30; if ((touch.x

getting UIView in separate class for FXBlurView

北城以北 提交于 2019-12-11 11:19:34
问题 I am using FXBlurView but I am receiving a weird black line at the top when animating the blurView down. I have a UITable that is 3/4 up the ViewController and an image that is the rest. What is happening Is that it is only picking up the UITable and not the image, in the superview. So is there a way to get the superview to pick up both? or a replacement? I have read that this can be fixed by replacing the superview with the actual UIView FXBlurView captures the contents of its immediate

(iphone) set subview's frame outside of superview's bound?

让人想犯罪 __ 提交于 2019-12-07 11:41:48
问题 I noticed that I can place subview outside of superview's bound (either partly or fully). I wonder if that's acceptable, since it seems to be abnormal in usual iphone view programming. Thank you. 回答1: This is acceptable and sometimes even common practice - custom implementations of scroll views or other "composite" views, for example, commonly place or move objects outside the superview's bounds. You may be interested in the UIView property clipsToBounds, which restricts subview drawing to

superview and parentviewcontroller nil after adding a subview

限于喜欢 提交于 2019-12-07 07:38:31
问题 I think I'm missing something fundamental and so I want to ask the community for some help. I'm building an app based around a basic iPhone Utility Application. My MainView and FlipsideView share some elements so I have created separate ViewControllers and nib files for those pieces. In order to do this I have done the following: 1. Created a viewcontroller called searchDateViewController which is the file's owner of searchDateView.xib 2. searchDateView.xib is basically a UIView with a

How to make a subview fill its superview

喜你入骨 提交于 2019-12-05 20:50:49
问题 I can't find the answer here anyway, nor do I see a duplicate question. My code is simple. Given 3 UIView, parent, from and to, remove from from parent and add subview. + add animation but that's just doodads. Now, the problem is when I do that, the to then get offsetted. It's as if it's pushed down. I even add To.frame=ParentView.frame; to make sure it works. It doesn't. What should I have done? + (void) AnimateSwitchingWithParent: (UIView *) ParentView From: (UIView *) From To: (UIView* )

(iphone) set subview's frame outside of superview's bound?

浪子不回头ぞ 提交于 2019-12-05 15:37:48
I noticed that I can place subview outside of superview's bound (either partly or fully). I wonder if that's acceptable, since it seems to be abnormal in usual iphone view programming. Thank you. This is acceptable and sometimes even common practice - custom implementations of scroll views or other "composite" views, for example, commonly place or move objects outside the superview's bounds. You may be interested in the UIView property clipsToBounds , which restricts subview drawing to only the bounds of the superview. Also note that out of bounds sub views pose a problem when implementing

Changing superview breaks UIPanGestureRecognizer

徘徊边缘 提交于 2019-12-05 12:11:41
I'm trying to implement a UIView that can be dragged out of its superview. I tried adding a UIPanGestureRecognizer to the view I want to be able to drag. It seems, however, that removing the UIView from its superview and adding it to another view, is breaking the gesture recognizer. With the code within the UIGestureRecognizerStateBegan commented out, the code within the other two blocks functions correctly, but when I reinstate it, the UIGestureRecognizerStateChanged and UIGestureRecognizerStateEnded states are never achieved. What is going wrong? if ([gr state] ==

How to update Superview from its Subview in iPad?

非 Y 不嫁゛ 提交于 2019-12-05 09:41:38
问题 I have a UISegmentedController i have 3 UIViewControllers Like photos,frames,gallery. I add those 3 Views in Superview Using 'addSubView'. In frames view i have added a subview that name as EditView. In EditView i have done some changes, i want to update these changes in frames view. But when am removing EditView from frames view any single method doesn't calling. Then how to update the changes from subview in superview. Tree: UISegmentedController -> Frames(Su) -> EditViews(Subview). Can any

Swift find superview of given class with generics

天大地大妈咪最大 提交于 2019-12-05 01:31:46
I guess I'm struggling with generics. I want to create simple UIView extension to find recursively a superview of class passed in the function param. I want the function to return optional containing obviously either nil, or object visible as instance of provided class. extension UIView { func superviewOfClass<T>(ofClass: T.Type) -> T? { var currentView: UIView? = self while currentView != nil { if currentView is T { break } else { currentView = currentView?.superview } } return currentView as? T } } Any help much appreciated. Swift 3/4 This is a more concise way: extension UIView { func