Swift 4 - UIProgressView coming up as UIView - swift

Putting a ProgressView into a ViewController.
When I drag the ProgressView over to create an outlet the option comes up as UIView and not UIProgressView. What am I doing wrong?
Using Swift 4/Xcode 10.2.1

Hate to say it but you must be dragging the wrong view. Just added a Progress View to a project and control + dragged it across and got this:
It's easier to control + drag specific views from the left hand side navigator sometimes instead of directly from the story board.
Edit: Other than that I would try removing it and adding it again and/or restarting Xcode.

Related

Forcing a UIImageView to Remain in Front of an Active Animation

Language: Swift, IDE: Xcode for iOS development, Single View Application > View Controller...
I have 2 UIImage Views with identical images that I'm scroll-animating from left to right across the view in order to create a 'slowly-moving background' of sorts. I'd like to place other UI elements (Labels, other images, etc.) in the foreground of this repeating background animation, but find when I run the simulator the foreground image isn't seen...
Question: Is it possible to force other UI elements to stay in front of a repeating animation programmatically?
I'm not at my Mac so I can't share my code at the moment, but if you know a straight answer to the question and/or which method could best achieve this, I'm all ears!!
Thanks in advance! :)
This depends on the z-ordering of the views. Assuming you are adding all of your views then starting the animation call bringSubViewToFront on the view you are animating right before you start animating it. If you are laying things out in interface builder the Z order is based on top = farthest and bottom = closest. If you are adding view programmatically the newest view is always added in front. You can change this with insertSubview:at: and the related methods. Take a look at the documentation for UIView.
If you want z-index use:
YourImageViewName.layer.zPosition = 1
Also you could play with bringToFront method on the parent view:
self.view.bringSubviewToFront(YourImageViewName)
Hope this fix your problem.

Adding ViewController's View as subview to UIPageViewController in iOS 8 gives weird UINavigationBar while show/hide

I have been working on a project where I needed to show list of images with zoom / swipe feature as presented view modal. I created custom ImageViewer using ContainerView in which I have added UIPageViewController. And on demand, I added ImageViews over the UIPageViewcontroller's view. When user taps to imageView, the top UINavigation gets shown and hidden on toggle basis.
Everything worked as expected in iOS 7.1 and less. However when I tested the functionality in iOS 8 devices and simulator, the ImageViews were not added to UIPageViewController in TopLeft ( beneath UINavigationBar ). It is added below the NavigationBar as shown in bug_iOS_8.png below.
Once I touch the buggy view, it repositions itself to correct position as in image expected.png below.
I have created and tested the issue in sample project and it seems it is bug in iOS 8 itself with UIPageViewController. I went through couple of questions regarding weird behavior of UIPageViewController too. Please check the sample app here and kindly let me know if anyone has any hints on what is going on.
Thank you for your time and help.
PS: BTW I am using following version of Xcode.
Update 1:
I have tried as per the pin suggestions. However, the problem aligning is with the main view of UIViewController rather than its subview. In below image, Yellow is main View of UIViewController and red one is added subview, I added pin to "red" on in reference to superview "yellow" one. Please check following screen shots.
On startup.
After touch on screen.
Kind Regards,
check in storyboard for particular viewController and make sure Extended Edges >> Under top bars is not selected.
I had a very similar issue and the way i fixed it was select the view being added to the UIPageViewController in the storyboard and selected the pin options. Below in the image you can see the Constrain to margins options, make sure you unselect that. Also when choosing what view to pin it to make sure you select the superview and not the Top Layout Guide.
Curious are you hiding your nav controller like this?
[self.navigationController setNavigationBarHidden:YES];
also if you have multiple Nav controllers, you might need to check you are referencing the correct one.
If you want it to be hidden when you present the ViewController you should move it to
-(void) ViewWillAppear{
}

Buttons move themselves after upgrade to Xcode 5

This is something that I've brushed off for a while now, but needs to be fixed. Recently, I upgraded to Xcode 5. After the upgrade, the buttons on the initial view will move after being clicked. This only affects that view, and none of the other views. This is odd, because the main view has no attached code to it - it is just a default UIViewController class. I tried creating a custom UIViewController class and linking the view to it, and I've tried deleting the button and recreating it - but they still move when clicked. Has anyone else had this problem after they upgraded to Xcode 5?
Before I click a button
And after I click a button
I suspected the problem is with the new Auto layout and the constraints. I have had similar issues with this when an object redraws it moves. Normally mine are when I expand a NSWindow (OSX) the objects inside its view fly off into a different position.
I would suggest you read the Documentation on Auto Layout guide and then have a look at how your buttons are set up. The is also a section on how to debug issues.
This is most likely happening due to auto layout. You have two options:
Add auto layout constraints that will position them in fixed positions, so that way they will never move.
Disable auto layout for your storyboard or XIB that contains the view controller.

Connecting outlets for custom UITableViewCell's in XCode 4 for iOS 5

In XCode 4 for building iOS 5 apps, I can create custom UITableViewCells. I have created a subclass of UITableViewCell and created a prototype cell. I have assigned the subclass to that prototype cell. Then I can use the cell. That's no problem.
But I cannot get XCode 4 to allow me to drag-assign the outlets of the subclass to refer to views inside the cell. I have to write the properties manually and then drag-assign them. Does XCode 4 capable of this?
![Connecting the outlet in Xcode4 IOS 5][1]
Man, exactly what I was wondering. Connecting custom cells in storyboard just seems not finished.
How to make it work:
Create CustomCell class, identify this custom class in the right, Utilities / Identity inspector
Add the IBOutlets to the .h manually
Drag the UI elements on the cutom cell in the storyboard, so they are available in the Document Outline.
In the Document Outline, right click context menu for the element outline, from + drag to the custom cell, let go, the second context menu appears and lets you select from your previously defined IBOutlets.
(CTRL-click drag from the element itself to the .h file just doesn't work.)
(PS:
Oops blabla,
We're sorry, but as a spam prevention mechanism, new users aren't allowed to post images. Earn more than 10 reputation to post images.)

Interface Builder / Putting UIButton in front of UIImageView (when UIButtons have been created before UImageView...)

I have already defined several buttons in a view with Interface Builder. Now, I would like to add an UIImageView in this view. The idea is to have the UIImageView display behind the already existing buttons. I have dropped a new UIImage View in the view but curiously, I cannot get the image appear under the buttons (buttons are hidden by the fresh UIImageView). When I move my old buttons onto the UIImageView, then they remain in front of them but I guess there is another way to reach what I want. Is not there a concept of "foreground/background level" for each object ? I also noticed that dropping a new button works fine. But I do not want to redefine all my existing buttons are they are already connected to my code.
Thanks for your help
Apple 92
You can just open the Document window of the IB (Click on Window--> Document).
Once opened expand the view block and drag the UIImageView just added above the UIbuttons previously added in the list. This will do the needful
Hope this helps!!