addsubview

WKWebView added as Subview is not resized on rotation in Swift

妖精的绣舞 提交于 2019-12-03 05:24:18
I'm working on adding a new reading view to my browser app. It is another view controller, that only includes a WKWebView added as a subview with a button (and gesture) to close the view. Everything works great, but when I rotate the device, the subview isn't resized, so I have one half of the screen empty. The WKWebView in the Reading View gets the URL of the main View Controller with a segue performed after the user taps a button on the main View Controller and that URL is stored as webpageURL. Here is the code I used: import UIKit import WebKit class ReadingViewController: UIViewController,

Add subview using storyboard without external xib

亡梦爱人 提交于 2019-12-02 19:20:22
I'm learning Objective-C. I have a problem with new storyboard feature. I would initialize a subview inside a main view with xib. Without using storyboard, I could do it using: controller = [[UIViewController alloc]initWithNibName:@"NibName" bundle:nil]; [self.view addSubview:controller.view]; Now, I wouldn't use an external xib, but I want manage a view in a class and use it like a subview in another class. I know that is possible use a xib and use a similiar code to load it, but it must be out the storyboard. django-d First create the view in your storyboard and then instantiate it with the

How do I add a UIview to an imageView while ensuring that the contents of the UIView are inside the it's frame?

我怕爱的太早我们不能终老 提交于 2019-12-01 09:34:10
问题 I have a superview which contains a ImageView , a testView , and some buttons. I created a UIView which contains ImageView2 and a removebutton . When I add UIView to UIImageView , the contents of UIView are not in the frame of UIView . Because of that, I cannot apply pan gesture recognizer. I have tried to apply constraints and to change the frame and centre of ImageView2 . Below is the code I am using to create the above mentioned UIView . How do I ensure that the contents of the UIView are

iPhone/iOS: Will there be called any method if a UIView is added as a subview

荒凉一梦 提交于 2019-12-01 02:50:48
If I add a view as a subview like so [self.view addSubview:mySubview]; Will there be called any method on mySubview, that I could override to add some custom behavior? Adding a view to a (new) superview triggers - (void)willMoveToSuperview:(UIView *)newSuperview and - (void)didMoveToSuperview . See the UIView Reference for more. You can override these two: - (void)willMoveToSuperview:(UIView *)newSuperview - (void)didMoveToSuperview Take a look in the documentation for UIView for similar methods. Yes, There is a method which get called if one change the superview . you need to override the

Adding a UIActivityIndicator to a modal view (ELCimagepicker)

∥☆過路亽.° 提交于 2019-11-30 23:30:37
I've added the ELCimagepicker (https://github.com/Fingertips/ELCImagePickerController) to my project and it works perfectly, allowing the user to select multiple images for a slideshow. But when you click 'Save', there can be a lengthy delay depending on how many photos were added. I've been trying to add a UIActivityIndicator when the user clicks 'Save', but having trouble due to the modal view that is presented. I can call a method from the activity that ELCimagepicker presents (ELCImagePickerController) and this gets actioned by the activity handling the presenting of the image picker. But

Adding a UIActivityIndicator to a modal view (ELCimagepicker)

你。 提交于 2019-11-30 18:32:11
问题 I've added the ELCimagepicker (https://github.com/Fingertips/ELCImagePickerController) to my project and it works perfectly, allowing the user to select multiple images for a slideshow. But when you click 'Save', there can be a lengthy delay depending on how many photos were added. I've been trying to add a UIActivityIndicator when the user clicks 'Save', but having trouble due to the modal view that is presented. I can call a method from the activity that ELCimagepicker presents

why is my UIView subview not rendering within the parent? (code attached)

萝らか妹 提交于 2019-11-30 17:17:07
Why is my custom UIView not rendering within the UIView container of it's parent? So what I have is: MainViewController - has a UIView " customViewContainer " (which doesn't take up the whole screen), and CustomView - is a UIView with a XIB file - it is the UIView here that when it is rendered (with AspectFit) is rendering outside the bounds of the parent " customViewContainer " The code used to setup the custom view is this extract from MainViewController: << cut - see Update2 below >> So I can't see why the CustomView view is being rendered in a way that is larger in area than the parent

addSubView to UIButton

与世无争的帅哥 提交于 2019-11-30 11:16:08
问题 I'm trying to add subviews to a UIButton. This is working fine right now. But the button isn't clickable anymore as soon as I add the subviews. I use the following code: UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom]; button.frame = CGRectMake(column*100+24, row*80+10, 64, 64); [button addSubview:asyncImage]; [button addSubview:price]; [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside]; The button works again if I cut out

UIView addsubview after orientation change: Tell view to resize

纵饮孤独 提交于 2019-11-30 04:06:00
问题 I have a UIView as a XIB in Portrait mode. This view is added programmatically to the viewcontroller like this: NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:@"InputView" owner:self options:nil]; InputView *inputView = (InputView*)[nibObjects objectAtIndex:0]; [self.view addSubview:inputView]; This view has autoresizing masks set up properly and rotates fine when the orientation changes from Portrait to landscape. However, if the orientation is already landscape and I create the

addSubView to UIButton

做~自己de王妃 提交于 2019-11-30 00:20:26
I'm trying to add subviews to a UIButton. This is working fine right now. But the button isn't clickable anymore as soon as I add the subviews. I use the following code: UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom]; button.frame = CGRectMake(column*100+24, row*80+10, 64, 64); [button addSubview:asyncImage]; [button addSubview:price]; [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside]; The button works again if I cut out the 2 addsubviews. If anyone knows how to fix this it would be great! THNX!!! I found a quick solutions.