subview

how to use addChildViewController in subview

这一生的挚爱 提交于 2019-12-01 10:44:20
I want to use addChildViewController in View (one view fro subviews array) but I don't know about that. this is my code : for (UIView *subview in self.view.subviews) { if (subview.tag == 1) { CartView *cart = [[CartView alloc]init]; [cart willMoveToParentViewController:????];/* (UIViewController*) from subview*/ [cart.view setFrame:CGRectMake(0.0f,CGRectGetHeight(self.view.frame),CGRectGetWidth(self.view.frame),CGRectGetHeight(self.view.frame))]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.3]; [cart.view setFrame:CGRectMake(0.0f,0,CGRectGetWidth(self.view.frame)

Passing data between views in ONE ViewController in Swift

為{幸葍}努か 提交于 2019-12-01 10:34:21
All of the searches I've done focus on passing data between view controllers. That's not really what I'm trying to do. I have a ViewController that has multiple Views in it. The ViewController has a slider which works fine: var throttleSetting = Float() @IBAction func changeThrottleSetting(sender: UISlider) { throttleSetting = sender.value } Then, in one of the Views contained in that same ViewController, I have a basic line that (for now) sets an initial value which is used later in the DrawRect portion of the code: var RPMPointerAngle: CGFloat { var angle: CGFloat = 2.0 return angle } What I

IOS, UIView, Detect Hidden State Change in Subview

余生长醉 提交于 2019-11-30 18:14:13
Is there anyway to detect a hidden state change (or other change) in a sub view in a UIView (not UIViewController). Would like to detect this async somehow. There are reasons for my madness. You can use KVO (key value observing) to detect a change to the value of the property hidden . Add your observer ( self in this example) in the following way: UIView* viewToObserve = [self getViewToObserve]; // implement getViewToObserve [viewToObserve addObserver:self forKeyPath:@"hidden" options:0 context:NULL]; Now add the following method to your observer class: - (void) observeValueForKeyPath:

Incorrect number of objects getting added to mutable array

送分小仙女□ 提交于 2019-11-30 09:23:45
问题 I have a view controller with table view that contains 8 cells(sections).I have created a textField and added that text field as a subview to 6 cells,remaining 2 cells of which one cell contains a text view and the other with a button.Because I am using the same text field,I have assigned tag values and then created a mutable array,added the textfield to that array.Here is the implementation code: Taking in regard the suggestion given by Mr.Lanc,I have changed the implementation code EDIT -

iPhone subview flip between 2 views

六月ゝ 毕业季﹏ 提交于 2019-11-30 07:03:32
iPhone / Objective-C On my view a little "hover" view appears after a user clicks on a button on the main view. When the user clicks this subview I want the subview to FlipFromRight to another view (same size). The main view underneath should stay. viewHot and viewCold are the subviews viewMain is the main one. Is this possible? Create another empty view in viewMain called viewHover and position it where you want the hover views to show. Then in IB add either viewHot or viewCold (not both) as a subview of viewHover. Then call a method like this to flip the views: -(void)flipViews { [UIView

Scrollview with embedded tableview

こ雲淡風輕ζ 提交于 2019-11-30 06:49:50
I'm building an iOS app in swift with Xcode 6. I'm trying to embed a view controller with a table view in a scrollview. When the user drags in the table view, it is suppose to move the table, not the the scrollview that it is embedded in. I've made this illustration, to clearify my view and view controller hierachy: The red area is the content size area of the scrollview . The green and blue areas are different view controllers , embedded in the scrollview. The yellow area is a Text field in the blue view controller. The orange area is a table view in the blue view controller. I have enabled

iOS: ScrollView infinite paging - Duplicate end caps

我的梦境 提交于 2019-11-30 05:57:14
问题 I have a question about infinite paging in a ScrollView. In my app I have only 3 subviews in ScrollView. Each subview is loaded from xib file. Normally it looks like ABC in ScrollView. I wanted to make infinite paging so I added end caps and now it looks like CABCA. If the user is on the first C, it jumps to regular C and if user is on the last A, it jumps to regular A. Here is a code: - (void)scrollViewDidEndDecelerating:(UIScrollView *)sender { if (scrollView.contentOffset.x == 0) {

Warning from iOS “Do not add subviews directly to the visual effect view itself”

一笑奈何 提交于 2019-11-30 04:49:34
问题 I have a function below and when I link with the iOS 11 SDK, I get an error: Do not add subviews directly to the visual effect view itself, instead add them to the -contentView. The problem can be solved by changing let effectView = UIVisualEffectView(effect: UIBlurEffect(style: .dark))" to effectView = UIView() but the effect is not present that way. How can I keep using UIVisualEffectView instead of UIView ? I want to keep the effect. let imagePicker = UIImagePickerController() let

Removing and re-adding a subview with autolayout

﹥>﹥吖頭↗ 提交于 2019-11-30 04:13:11
When using autolayout, my understanding is that removing a subview ( while holding a reference to it of course), the removed subview still knows its autolayout constraints. However, when adding it back to the super view later, the subview no longer knows its frame size. Rather it seems to get a zero frame. I assumed that autolayout would auto size it to meet the constraints. Is that not the case? I thought auto layout meant don't mess with frame rects. Do I still need to set the initial frame rect when adding the subview, even with auto layout? Max MacLeod When removing the subview, all the

UIWebview won't zoom even after setting scalesPageToFit to YES

我怕爱的太早我们不能终老 提交于 2019-11-30 04:00:54
I have a UIWebview that is loaded as a subview when a user selects a tab on a UISegmentedControl . For some reason, I can not get it to allow pinch/zooming . I set the following code in the viewDidLoad: method, so it should work. self.myWebView = [[[UIWebView alloc] initWithFrame:self.view.frame] autorelease]; self.myWebView.backgroundColor = [UIColor whiteColor]; self.myWebView.scalesPageToFit = YES; self.myWebView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight); self.myWebView.delegate = self; [self.view addSubview: myWebView]; I tried loading a