FAQ Database Discussion Community


Accessing Navigation Bar Height and Status Bar Height

ios,swift,uiview,uiviewcontroller
I am currently developing my first iOS application using Swift and I am running into a lot of issues with the UI portion of app development. I have decided to do all of the views programmatically because enough of them are complicated enough that I think storyboarding would be major...

Using gesture of the subclass over the gesture of the parent class

ios,swift,uiview,uigesturerecognizer
I have a class MyView subclassing UIView which is basically adding a tap gesture to the whole view. I have another class MyViewWithTextField subclassing MyView. In this view, there is a UITextField to which I added a gesture. My problem is that when I tap on the UITextField, its gesture...

When replicating UIAlertView; background is not the same

ios,objective-c,uiview,uialertview
I'm creating a custom UIAlertView (from a UIView). I'm trying to get the same background effect (when the background view darkens). So I created a new black UIView with .5 opacity, and added it to the background. The problem is, I have a tab bar. When the black UIView covers...

UIView textured uitableview cell?

ios,uitableview,uiview
I am trying to emulate the texture that is used on these tableview cells http://pixelsbyrick.com/blog/alarmik.html I was wondering if apple allowed us to create a background texture layer then super impose a Color onto of it. This appears to be a metallic texture....

iOS Bring UIView up before keyboard?

ios,objective-c,uiview,keyboard
I have two UIViews inside my UIView. Here is my view: On textfield focused, keyboard is shown and keyboard hides my textield. I want to move whole TextField View up before keyboard. I've found code example here on stackoverflow: iPhone Keyboard Covers UITextField This is the code: - (void)textFieldDidBeginEditing:(UITextField *)textField...

Creating a subclass for a UIView for reusability

ios,objective-c,uiview,subclass,uitapgesturerecognizer
I have a DiscoverViewController.h and .m files that have a function that displaces views of places to discover. I want to reuse this view in output viewcontrollers too. The code for the DicoverViewController.m with the uiview is below: for (PFObject *views in objects) { // Get the discoverr view setup...

UIPanGestureRecognizer calculate frame origin to maintain adjacent subview position for image cropping

ios,objective-c,uiview,uipangesturerecognizer
I have a cropView that holds a cropBoxView subview that also holds four subviews that are square and each have a UIPanGestureRecognizer on them to enable resizing of the crop area. What I'm trying to do is change the frame size but maintain the adjacent square corner's position, which means...

Automatically Adjust UIView's Height to It's Subview using AutoLayout (Storyboard)

ios,xcode,uiview,uitextfield,autolayout
I am using StoryBoards and Autolayout. Below is the hierarchy: - Superview -- UIView (ContentView) --- UITextField --- UITextField --- UITextField --- UITextField The UIView(ContentView)'s is constrained to Left, Top, Right of the SuperView with the offset of 20; The Bottom of UIView(ContentView) is not constrained to anything. I would...

Load custom view from .xib doesn't fit to iPhone 6+

ios,iphone,uiview,autolayout
I m using Autolayout in my app. When I load my custom UIView from .xib from viewDidLoad it's size is (300,325) like it should be, but on iPhone6+ is't actually (394, 493). But when I load my custom UIView from .xib after that (somewhere) the size isn't change ( stay...

button.setTitle blanks out image view

ios,swift,uiview,uiimage
Can anyone tell me why setting the button.setTitle(string, forState) function blanks out the UIImage? If I comment out both lines that use the button.setTitle, the animation runs fine. When the lines are there, the animation disappears when I press the button. The var cryButton: UIButton and the function UpdateImage refer...

Creating infinite background scroll right to left

swift,uiview,uiviewanimation
I am trying to create an animation to create an illusion of moving object. So the object will stay at the same position but the background image view which is wider than screen width will move infinitely. The code I have doesn't work very smooth. let backgroundView = UIView() backgroundView.backgroundColor...

Flip a scaled and rotated uiview in objective c

ios,objective-c,uiview
I am trying to flip a scaled and rotated uiview on the horizontal axis. Here is the code being used - CGFloat xScale = selectedFrame.transform.a; CGFloat yScale = selectedFrame.transform.d; selectedFrame.layer.transform = CATransform3DScale(CATransform3DMakeRotation(M_PI, 0, 1, 0),xScale, yScale,-1); The output of this is that the view flips properly and the original scale...

How to disable didSelectRowAtIndexPath on UIView Tap inside custom TableViewCell?

ios,objective-c,uitableview,uiview
I have a UITableView with custom TableViewCell inside that custom UITableViewCell there is a UIView(myView). I want to disable didSelectRowAtIndexPath when I tap on myView,didSelectRowAtIndexPathshould not be called when I tap on myView. it's not same as this question because in that question it's not clear what the user want...

How to move up a modal UIView inside of a UIViewcontroller (StoryBoard)

ios,iphone,uiview,uiviewcontroller,keyboard
i've got a UIView, dragged of Object Library, inside of a UIViewcontroller created by StoryBoard. Inside of this UIView, I put two Text Field to grab user name and password, and one button to log in. How can I move only this View when the keyboard appears? I'm able to...

UIView Animation not shown after segue

swift,uiview,uicollectionview,uilabel,uiviewanimation
I have 2 View Controllers. The first one is a Collection View Controller, the second a plain View Controller. When clicking a cell in the Collection View Controller, the second View Controller appears. When the view starts to load in the 2nd view controller, I want to show a UILabel...

Scene Kit: projectPoint calculated is displaced

ios,swift,uiview,scenekit
I am trying do draw an frame over a sphere on the parent view of the scene, but for some reason the points converted by SCNScene.projectPoint method are displaced. To make it simple, i created a sphere at the center of the scene with 2 radius. The sphere is attached...

How to fill the background image in a UIView without streching it

ios,swift,uiview
I'm trying to set the background image of a UIView with animated .gif's that I'm pulling form Giphy. The problem I'm having is that the UIView is stretching the image. I want to fill the background so the height is 100% and have it centered. So left and right of...

How to send a UIView element backwards in Swift

ios,iphone,swift,uiview
So I have a Button which i have added in main.Storyboard, along with a main background for the View, and then in the viewController.swift file, I have created a UIView rectangle shape which I want to sit behind that button (as a background for it). The problem is, when I...

UIView.hidden doesn't work immediatly

ios,objective-c,iphone,uitableview,uiview
I have a UIViewController with a UITableView and UIView (see blow). When I call hiddenLoadingView at somewhere, the UIView is still showing, then dismiss after 10-20 seconds, why? - (void)viewDidLoad { .... self.tableView = [[[UITableView alloc] init] autorelease]; [self.view addSubview:self.tableView]; self.loadingView = [[[UIView alloc] init] autorelease]; [self.view addSubview:self.loadingView]; } -...

Swift How to convert a UIview to a image

ios,swift,uiview,screenshot
I want to convert a UIView to an image and save it in my app. Can someone please tell me how to take screenshot of a view or convert it to an image and what is the best way to save it in an app (Not camera roll)? Here is...

Error trying to make a circular UIView in Swift

ios,iphone,swift,uiview,cornerradius
I have an UIImageView in my screen layout which dynamically resizes according to the container view dimensions. I would like to transform it in a circular view and I'm using the following code: let dSize: CGFloat = min(imageview.frame.height, imageview.frame.width) imageview.frame = CGRectMake(0, 0, dSize, dSize) imageview.clipsToBounds = true imageview.layer.cornerRadius =...

Draw/Paint like sketch color inside a bezier path in UIView

ios,objective-c,uiview,core-graphics,uibezierpath
I am drawing a shape layer with help of a UIBezier Path on a UIView : CAShapeLayer *pathLayer = [CAShapeLayer layer]; pathLayer.frame=CGRectMake(-view.frame.origin.x, -view.frame.origin.y, view.frame.size.width, view.frame.size.height); pathLayer.path = path.CGPath; pathLayer.strokeColor = [[UIColor blackColor] CGColor]; pathLayer.fillColor = [[UIColor clearColor] CGColor]; //pathLayer.fillColor = nil; pathLayer.lineWidth = 6.0; pathLayer.lineJoin = kCALineJoinBevel; [view.layer addSublayer:pathLayer]; On...

Is deeply nested view hierarchy in iOS ok?

ios,uiview
In Android it is recommended that the view hierarchy depth be kept under 10, and strictly under 20 or else your app is very likely to perform poorly or crash (UI thread only a tiny 8-16kB of stack space) Does this hold true for iOS, with or without autolayout (why...

Create a UIView title of a push view using the index of an array

iphone,uitableview,uiview,titlebar,nsrangeexception
I have a UITableView that pushes to a UIView when the user taps the UITableViewCell. I want to make the title of the push view the text from the cell that the push view is coming from. I am trying to declare an NSUInteger when the row is selected to...

Trying to place a UIView over top of a UIImageView to highlight a section of UIImage

ios,uiview,uiimageview,uiimage
I am building an app that displays text from a book on the screen. The text of the page is aUIImage, and is contained inside of aUIImageView on the screen. What I would like to do is highlight each line of the page, using aUIIView that is placed over top...

NSLayoutConstraint conflict. UIView-Encapsulated-Layout-Height

ios,uitableview,uiview,autolayout,nslayoutconstraint
I am having some problem with autoLayout. Particularly in iOS8. I have already read the net and found similar issues when usingUITableViewCell. But here I am not usingUITableViewCell and have noUITableView at all. When it happens I only have aADBannerView and aUIWebView to deal with. I get the following message...

Wrong alignment of subviews in a UIScrollView

ios,objective-c,swift,uiview,uiscrollview
I have the following code, which creates UIView, and some of its subViews, and adds them to a UIScrollView, all in a loop : var count:CGFloat=bookScrollView.frame.minX for var i=0;i<10;i++ { var view=UIView(frame: CGRect(x: count + 20, y: bookScrollView.frame.minY + 30, width: 200, height: 300)) view.backgroundColor=UIColor.whiteColor() view.layer.cornerRadius = 5; view.layer.masksToBounds =...

DRAGGED uiview iOS

ios,objective-c,iphone,uitableview,uiview
I'm using SIZES CLASSES in iOS storyboard. I want to load a uitableview in a uiview on simple button action. What I'm facing is dragged view from left to right on first open. button when I click the button, it shows normal in UIVIEW's frame. I also given a trailing...

Drawing in UIView on touch points gives blurr drawing effect on boundaries

ios,objective-c,uiview,core-graphics,calayer
To sort out my last problem : Draw/Paint like sketch color inside a bezier path in UIView, I took an exact Image (of path) filled with selected color. Then, to draw that in UIView, for context color I took: lineColor=[UIColor colorWithPatternImage:img]; in drawrect : CGPoint mid1 = midPoint(previousPoint1, previousPoint2); CGPoint...

How to increase height of UIButton image without moving button

swift,uiview,uibutton
I have added a UIButton to storyboard and then added my image to the button. What I am looking to do is when you tap on the button the height increases slightly and then the button decreases in height by about a quarter. @IBAction func StopsClick(sender: UIView) { //Get the...

iOS CGRect is inside another CGRect

ios,uiview,cgrect
Anyone has a good solution for the following task? I need to check if a CGRect is inside another CGRect and return a CGPoint, that gives the offset if the rect window is outside in any dimension from the containing. thanks in advance...

fill part of a UIView with color with animation

ios,objective-c,uiview
I need to create effect of filling a UIView with color, with animation. For example as a battery image is filled with background color . So i can see the problem as 2 : background color of a UIView but only part of it ( 10% / 45% /etc )...

iOS swift multi-line UILabel in a view

ios,uiview,autolayout,uilabel,multiline
I would like to accomplish what is seen in the image below in Interface Builder. Basically two labels - one multi-line and one note - inside a view and the view centered horizontally on the page. So to be clear, I cannot put a width constraint on the view or...

How to change Custom Cell's UILabel Text?

ios,objective-c,uitableview,uiview,uilabel
I have a table view with a custom protoype cell and the cell has 3 different labels on it. How do I get access to these labels? I need to change their texts. I've searched around everywhere and haven't found something that helps me in this case. I have the...

Loading UIViewController “from” Nib File

ios,xcode,uiview,uiviewcontroller,xib
I am trying to create an UIViewController from a Nib file. On Google I found that I can only load an UIView from Nib. But some suggests that I could create a Nib file (of UIView) whose File Owner is set to our ViewController. That is what I did, I...

Changing UIView background color using an animation

ios,objective-c,uiview,uiviewanimation,caanimation
I want to change my UIView background color with a transition animation. For example, if the view is red and I change it to blue. The blue color will slide up from the bottom of the screen to the top and fill the whole screen. I was thinking of doing...

swift - UILabel text not renderer when using renderInContext asynchronously

ios,image,swift,uiview,rendering
I need to generate an image from a custom view composed by an UIImageView and an UILabel. I can't use the new iOS 7 drawViewHierarchyInRect:afterScreenUpdates: because I have some ugly glitch on iPhone 6/6+ (iOS8 scale glitch when calling drawViewHierarchyInRect afterScreenUpdates:YES) So I did it the old fashion way using...

How can I drag my UIView only from a specific area of this UIView?

ios,swift,uiview
This is the UIView I would like to have. Most of it would be hidden and could be dragged out ONLY by dragging the little visible part. I thought about drawing my view up to let say 90% of its container and on the top, draw a little rectangle (the...

Do I really need drawRect() in custom UIView?

ios,uiview,drawrect
I am new to iOS and trying to understand the use for drawRect() in custom UIViews, so I have simple custom view which I initialize from code.I want to update its colors for instance and I see two approaches as shown below. Which one should I use and why? //VController...

What is the best practice for loading different objects into UIViews Swift

ios,swift,uiview
I am a high school student working on a program that connects to a database and displays information in an application. This part works. I would like to have a single UIViewController that loads different pieces of information based on a UISegmentControl selection in an UIView. What is the best...

UIBlurEffectView smaller than autolayouted parentView although identical frame

ios,swift,uiview,autolayout,uivisualeffectview
I have an UIView for login purposes centered in the middle of the screen. It is constrained to a 0.25 height of the surrounding view (covering the whole window) I noticed, that if I create an UIVisualEffectView (via the method blurBackgroundForView(_)as background for the UIView, that it is too small...

Crash in self.view after constructor on iOS 8.1 and 8.2

ios,xcode,uiview,uiviewcontroller
I'm trying to do a simple SpriteKit action - adding a view to a scene: UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"LevelsEditorStoryboard" bundle:[NSBundle mainBundle]]; self.levelsEditor = [mainStoryboard instantiateViewControllerWithIdentifier:@"LevelsEditorId"]; [self.scene.view addSubview:self.levelsEditor.view]; On iOS 8.0 and 8.3 is working fine and on iOS 8.1 and 8.2 I'm getting the following error: SPBingo[75304:80943666] *** Terminating...

Rounding corner causes top edge to blur

ios,swift,uiview
I have a UIButton subclass that I am rounding the corners of. Using either the usual cornerRadius property on its layer, or creating a rounded mask and applying that to the layer, I always get the effect shown in the image below (blown up so you can see it clearly)....

Change height of UIView inside of UITableViewCell (Storyboards)

ios,objective-c,xcode,uitableview,uiview
I'm trying to create a master UITableViewCell with storyboards. The idea is that this cell contains all the possible subviews, but not all will be shown depending on the data for each cell. I calculate the appropriate height for each cell depending on the data using the heightForRowAtIndexPath and this...

Get only the NAME of PARENT CLASS through any of its UI elements (eg. button, label, textfield) [duplicate]

ios,objective-c,class,uiview
This question already has an answer here: Get to UIViewController from UIView? 17 answers I am trying to get the class name of a UIViewController through one of its UI elements. When called in the following manner, the class method returns the correct name (eg: myViewController): NSLog(@"Class name: %@",...

Is it not possible to create a UIViewController programmatically without building the view?

ios,cocoa-touch,uiview,uiviewcontroller
I want to create a UIViewController programmatically. No nibs or storyboards. It will basically be created and then presented, and in its own class it will set up an image to be displayed. However, whenever I just alloc init a view controller and present it, it comes out black as...

Pass NSArray to UIView

ios,objective-c,uiview
I presumed this would be simple but it is not working. I am trying to pass an NSArray to my UIView that is getting imported with a NIB.I am importing it as: DraggableViewBackground *draggableBackground = [[DraggableViewBackground alloc]initWithFrame:frame]; draggableBackground.exampleCardLabels = @[@"Mercedes-Benz", @"BMW", @"Porsche", @"Opel", @"Volkswagen", @"Audi"]; [self.ripContainer addSubview:draggableBackground]; On my DraggableViewBackground...

Are View Controllers required for an iOS App?

ios,objective-c,iphone,uiview,uiviewcontroller
I have been studying the iOS app structure, and almost got my head around the MVC paradigm, with the delegates, views and controllers. Then I came across an example on the net that comprised of just one AppDelegate file, with no views, view controllers, or nib files, and it works:...

Container View's Frame Set to CGRectZero when Using Programmatic Auto Layout

ios,objective-c,uiview,uiviewcontroller,autolayout
I have a UIView subclass that will be a tooltip that can appear on the bottom of any view controller to show a hint/error message/success message/etc. The tooltip view has two subviews: a UILabel on the left-hand side and a UIView on the right hand side, that can be anything...

Passing information from one UiView to Another

ios,objective-c,uiview
I am beginning to learn Objective-c and my problem is the following: I have created a UIView to create a profile and in that UIView, i have an imageView for the Picture as a Datepicker for the Birthday and a Slider for the Weight of the person. When the user...

Multiple ways to present UIViewController's view [closed]

ios,objective-c,uiview,uiviewcontroller
I'm fairly new to iOS and working on someone else's project, and I notice that there seems to be various different ways to present a view. I'm wondering if someone could give a brief summary of the various ways to present a view, and when to use which one, because...

Google Maps SDK crash on ItunesConnect test not Xcode

ios,objective-c,google-maps,uiview,gmsmapview
Google Maps SDK makes my app crash, I don't know what I'm doing wrong... I put my GMSMapView in a UIView in interface builder. Here is my code : Contact.h : #import <UIKit/UIKit.h> #import <MessageUI/MessageUI.h> #import <ParseFacebookUtils/PFFacebookUtils.h> #import <GoogleMaps/GoogleMaps.h> @interface Contact : UIViewController <MFMailComposeViewControllerDelegate> - (IBAction)openMail:(id)sender; @property (weak, nonatomic) IBOutlet...

Swift cant resolve CurveEaseIn in UIView.animateWithDuration when using parameter from function inside animation block

ios,swift,uiview,uiviewanimation
I am trying to pass parameter to function to change layout constraint in animation block dynamically. This works: func moveKeyboard (up: Bool, newMargin: Int) { UIView.animateWithDuration(0.2, delay: 0, options: .CurveEaseIn, animations: { self.topMarginConstraint.constant=10; }, completion: { finished in println("Animation end!") }) } and this doesn't (i get error "Could not...

View does not animate

swift,animation,uiview
I have a view, which shall move up like a drawer from the bottom of the screen. But it does not do anything. It just sits there =) Can anyone please tell me, why it is doing that? This is my code: import UIKit class InfoPopUpVC: UIViewController { var superView:...

Add UISlider to UIView

ios,swift,uiview,uiviewcontroller
I am trying to add a UISlider to a UIView to add to my UIAlertController for an easier but am unsure of the method. In Objective C you would call addSubview but I am unsure of what it is in swift. //UIViewController.alertReminden(timeInterval) var refreshAlert = UIAlertController(title: "Reminder", message: "Set a...

Swift - UIView.transitionFromView -

swift,uiview,uiviewanimation,uiviewanimationtransition
What happens to your “fromView” after you use UIView.transitionFromView? How do you get it back? (re-initialize it?). Here’s a simple example I made and get “fatal error: unexpectedly found nil while unwrapping an Optional value” when I try to get back to the “fromView” or reference a label on it,...

Implementing an uiview subclass with children views using autolayout programmatically

ios,objective-c,uiview,autolayout,nslayoutconstraint
My need is very generic, I have to implement an UIView subclass which groups an UIImageView, x-centered on the screen and distant 20 pts from top, and a UILabel with a description. I have no problems doing it with interface builder, but since I needed to make it programmatically I...

Add a rectangle on the top edge of my UIView

ios,swift,uiview
I have a UIView that I create in xib file and integrated in my storyboard. This view is like a tab you can drag to make it appear. I would like to add a little rectangle on the top edge so that when my UIView is hidden, there is only...

How can I add a vibrancy effect to a subview?

ios,objective-c,uiview,uivisualeffectview,uiblureffect
The code below works fine for a simple: UIVisualEffectView *blurView But, when I try to add a label to it that has a vibrancy effect it breaks down in tears and errors. :( UIBlurEffect * effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; _blurView = [[UIVisualEffectView alloc] initWithEffect:effect]; _blurView.backgroundColor = [UIColor colorWithWhite:0.8 alpha:0.5]; [self...

AVCaptureVideoPreviewLayer displays correctly except on iPhone6

ios,objective-c,iphone,uiview,avcapturesession
I'm working on implementing a view that consists of an AVCaptureVideoPreviewLayer. The view is supposed to take up the entirety of the screen, except for the navigation bar at the top (the view is embedded in a navigation controller). My code below shows how I've set up a capture session...

UIView animation with sub-subview

ios,swift,uiview
So I want to animate a subview of a container view in my main view (essentially a sub subview), should I create another view controller for the subview to control the sub subview or create an outlet in the main view controller for the sub subview? The problem is that...

UIView's frame rendering larger than frame

ios,objective-c,uiview,uiscrollview
I am trying to add a subview to a UIScrollView. First I instantiate the view controller from the storyboard, then set the view's frame to the application bounds. When I add the view to the UIScrollView, it is clearly larger than it's supposed to be. CGRect mainFrame = CGRectMake(0, topButtonHeight,...

How to move a UIView programmatically in Swift

swift,uiview,move
The issue is to move an "InfoView" (UIView) programmatically in Swift. The following constraints exist in the storyboard (see image): Now, I would like to move the "InfoView" inside "MyView" up or down. I tried: @IBOutlet weak var infoTextLabel: UILabel! @IBOutlet weak var infoTextLabelView: UIView! // set infoTextLabel color self.infoTextLabel.textColor...

How to Preserve state of UIView Controller when it come back from Background

ios,objective-c,uiview,uiviewcontroller,uiviewanimation
I have created one login Page which have two uiTextField and Login Button. When you try to login Keyboard hide textfield and button, So I have used below code to move up and down view controller from textfield delegate methods. -(void)animateTextField:(UITextField*)textField up:(BOOL)up { int movementDistance = -130; // tweak as...

Working with transparency: View behind transparent view should only shine through and not overlap

ios,uiview,transparency
I'm currently working with transparency and I'd like to have the following effect: As you can see the line takes the full width of the view. There are some transparent UIViews also on this screen. The line seems to be below the transparent UIView and if it overlaps it has...

Enable user interaction for gesture recognizer during UIView.animateWithDuration()

ios,swift,uiview,uigesturerecognizer,animatewithduration
I have a view (A) that holds several rectangular subviews (B). Each of these subviews have a single tap recognizer to trigger an action. The parent view A also has a single tap recognizer that calls a function on A's controller to make each of the subviews B flash in...

UILabel is not centered in my UIView

ios,objective-c,iphone,layout,uiview
I'm adding a UILabel to a UIView on initialization and the label will not center itself. I've tried centering it is layoutSubviews and adding constraints programmatically with no luck. When it appears it is about 200 pixels to the left of the center. Here is my code. Thanks in advance....

CATransaction: a view flashes on completion

ios,uiview,core-animation,cabasicanimation,catransaction
I'm writing a little bit complex animation, which goes in 2 steps: Change opacity to 0 of UIViews that are not need to be visible and move a UIImageView (which has alpha = 1) to another CGPoint (position). Change opacity of another UIView to 1 and the opacity of the...

How to add custom UIView(xib) in custom UITableviewCell with the help of AutoLayout?

ios,objective-c,uitableview,uiview,autolayout
I have one View Controller in which I have one UITableView. I have used custom UITableviewCell with xib in that UITableView. Now I have one UIView with xib and I want to add that UIView's object in custom UITableViewCell with the help of AutoLayout. I added that UIView successfully in...

Overriding init() in a CustomUIView crashes app (EXC_BAD ACCESS)

ios,objective-c,swift,uiview,custom-controls
I am trying to subclass a UIView in Swift. Howver the app crashes (EXC_BAD_ACCESS) when the initializer is called Here is the class class CustomActionSheet: UIView { private var cancelButtonTitle: String!; private var destructiveButtonTitle: String!; private var otherButtonTitles: [String]!; convenience init() { self.init();//EXC_BAD_ACCESS } required init(coder aDecoder: NSCoder) { super.init(coder:...

Swift - Using CGContext to draw with finger

ios,swift,uiview,cgcontext
I'm trying to make a drawing app. I have a single custom UIView: class DrawView: UIView { var touch : UITouch! var lastPoint : CGPoint! var currentPoint : CGPoint! override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) { touch = touches.first as! UITouch lastPoint = touch.locationInView(self) println(lastPoint) } override func touchesMoved(touches:...

iOS - incompatible pointer types

ios,uiview,uiimageview
I get an warning: incompatible pointer types assigning to 'UIImageView' from 'UIView' with this code: if ([gestureRecognizer.view isKindOfClass:[UIImageView class]]) { curgraphicview = gestureRecognizer.view; } The code actually work. But in this case, How can I make it so that I don't have warning?...

Create a uiview xib and reuse in storyboard

xcode,uiview,autolayout,interface-builder,xib
I typically like to design my views in interface builder. Sometimes I need to create a single view in a xib that can be reused in multiple view controllers in a storyboard.

UIView is not moving up when keyboard shown AutoLayout

ios,objective-c,uiview
My UIView is not moving up when keyboard shown and disappear when keyboard is hidden as well. This coding is in ViewDidLoad [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardDidHideNotification object:nil]; and this coding is for the rest. - (void)keyboardDidShow:(NSNotification *)note { [self animateTextField:TRUE]; } -...

Add a 0.5 point height subview to UINavigationBar not show in iOS7

ios,objective-c,ios7,uiview,uinavigationbar
I have a class inherit from UINavigationBar and I want to add a separator line as its subview to separate the navigation bar and the navigation content. The line's height is defined as following. #define SEPERATOR_LINE_HEIGHT (1.0f / [UIScreen mainScreen].scale) My code: @interface MyPopNavigationBar : UINavigationBar @end @implementation MyPopNavigationBar {...

How to display AlertController in UiView

ios,swift,uiview,uialertcontroller
new to Swift. Below code is executed without error but in the console it show some message. Is this error message, how to fix it? Is this required to be fixed when sending app for certification. Thanks this is my App structure : VC(1) --> goto --> VC(2) In VC(1)...

Swift - How to properly architect buttons in MVC?

ios,swift,uiview,uibutton,segue
I had wrote a block of code which made a UIButtons in a UIView with a segue action all in the ViewController file. The segue action allows the user to press on the a UIButton and pushes a new UIView with the title of that button on it. This worked...

How to detect when UIView size is changed in swift ios xcode?

ios,swift,cocoa-touch,uiview,uiscrollview
I am trying some stuffs out with CATiledLayer inside UIScrollView. Somehow, the size of UIView inside the UIScrollView gets changed to a large number. I need to find out exactly what is causing this resize. Is there a way to detect when the size of UIView(either frame, bounds) or the...

Generated subview is always behind image view

ios,objective-c,iphone,uiview
viewController.m -(void) viewDidLoad { [super viewDidLoad]; [self addScoreRowViewWithIndexLeft:(++i) andName:[scoreDict objectForKey:@"name"] andScore:[[scoreDict objectForKey:@"points"] integerValue]]; } -(void) addScoreRowViewWithIndexLeft:(NSInteger)index andName: (NSString *)name andScore: (NSInteger)score { UIView *scoreRowView = [[UIView alloc] initWithFrame:CGRectMake(128, 112 + index * 80, 280, 20)]; UILabel *indexLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 20, 20, 20)]; UILabel *nameLabel = [[UILabel alloc]...

Continuous animation in iOS?

ios,uiview,catransform3d,animatewithduration,uilongpressgesturerecogni
In my case I have a view with content. I want to scroll this content on UILongPressGestureRecognizer events: if the touch position y is enough near the up view border then scroll up; if the touch position y is enough near the bottom view border then scroll down. I can't...

iOS UIButton click doesn't work

ios,objective-c,iphone,uiview,uibutton
I have an issue with iOS UIButton click handling programmatically. I have a UIButton: - (UIButton *)compareButton { if (!_compareButton) { NSString *title = TITLE; NSDictionary *attributes = TITLE_ATTRIBUTES; NSAttributedString *attributedTitle = [[NSAttributedString alloc] initWithString:title attributes:attributes]; _compareButton = [[UIButton alloc] initWithFrame:CGRectMake(0.0f, 20.0f, 100.0f, 44.0f)]; _compareButton.backgroundColor = [UIColor redColor]; [_compareButton setAttributedTitle:attributedTitle...

How to create a dragging animation for a UIView?

ios,swift,uiview
I have a hidden UIView at the bottom of my UIViewController. I would like to create an interactive animation that would show progressively my UIView, like if I was dragging the UIView from the bottom and it would follow my finger (location, speed, etc.). If I go over half way...

Cannot change the frame properties of a UIView

ios,swift,uiview,frame,nskeyedarchiver
I have a UIView @IBOutlet weak var myView: UIView! I copy it using NSArchiver var topview = NSKeyedUnarchiver.unarchiveObjectWithData(NSKeyedArchiver.archivedDataWithRootObject(self.myView)); I attempt to alter it using CGRectMake topview?.frame = CGRectMake(0, 0, self.view.frame.width, self.view.frame.height * 1.5) In response to the line above's '=' I receive the error Cannot assign to result of this...

Swift: remove layer, without removing UIView in UITableViewCell

ios,iphone,swift,uiview,calayer
I have UITableViewCell with UIView in it. I made some CABasicAnimation and attach it to new CAShapeLayer, then I add this layer to my super layer in my UITableViewCell: self.layer.addSublayer(myLayer!) All nice except that myLayer (and his animation) showing above my UIView. I want that label be below UIView. I...

Create Custom UIVview, circle with two color

ios,objective-c,uiview,draw
Theres any way that i can create a circle with two colors, like this : https://msresource.files.wordpress.com/2011/11/image4.png only detail, is the circle divides in a diagonal...

Objective c keyboard opens unwillingly

ios,uiview,keyboard,uitextfield,uitextview
I have a "layer builder" object which creates different views and returns them after initialising them. The problem is, whenever i press on one of these created views, the keyboard opens up and i can't understand why. This is how my layer builder is coded: @interface LayerBuilder : NSObject <VENTokenFieldDelegate,...

UITextField inside a UIView thats animated on touch dismisses the view and shows the keyboard

ios,objective-c,iphone,uiview
I have a structure for my UIView object and have form elements within it. I run the application and the program is in such a way that when i click a button inside the UIView, it moves the current frame upwards. But thats not the problem. My phonenumberfield is of...

Trying to get UIView to bounce using UIKit Dynamics

ios,objective-c,uiview,uikit-dynamics
I am trying to get a UIView that is in the shape of a circle to "bounce" using UIKit Dynamics. It is supposed to bounce when it reaches the bottom of the screen. The circle is a standard UIView that I create in the viewDidLoad method as follows: - (void)viewDidLoad...

Calling UIView from UIController

ios,objective-c,uiview
I am trying to call a UIView FirstScreen from my ViewController. But I don't know how to do it. ViewController: #import "ViewController.h" #import "FirstScreen.h" @interface ViewController () { FirstScreen *f; } FirstScreen.m: #import "FirstScreen.h" @implementation FirstScreen - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self didLoad]; } return...

DrawRect overriding properties of view

ios,swift,uiview,xcode6
I'm creating a custom view which will basically just be a checkmark inside a cirlce. I've created a circle using layer.cornerRadius = 0.5 * frame.width but when I override drawRect, it causes that line to be ignored and my view becomes a square. Why is this? And how can I...

Subviews of custom UIView are equal to nil even after view is loaded

ios,swift,uiview
I'm trying to render a custom view. The problem is that even after the view is loaded, its subviews are still equals to nil.. So not showing and impossible to configure. The custom view is setup through interface builder and all the outlets are linked to the properties you can...

Key-Frame Animation appears fuzzy when moving Frames?

ios,objective-c,swift,animation,uiview
I use JazzHands to create a key frame based animation in a UIScrollView. Here is an example. Look at the view at the top. When you move from page to page. While the animation is running the view at the top is slightly moving from left to right. The animation...

Redrawing UIViewController and its subviews

ios,xcode,uiview,uiviewcontroller,storyboard
I have a UIViewController with many subviews like UILabels, UIImages and a UIWebview. With a defined action by the user, the subviews of the UIViewController animate to different sizes and different locations inside of the UIViewController's view. Is it possible that this can be undone with a different defined action...

Swift Does Not Recognize This Specific Objective C Class Constructor

ios,objective-c,swift,uiview,constructor
I am trying to use this class REDActionSheet.h I've imported it into my bridging header and everything. I have other Objective C class as well. XCode seems to detect the class and I could initialize it normally. However, Swift does not seem to recognize the constructor for this class Here...

UIView respect uinavigationbar size storyboard

ios,objective-c,uiview,storyboard,autolayout
I have this UIView, wich is supposed to be fullscreen, but in my uiviewcontroller, i have an uinavigation bar. If i put the UIView inside it, with the same size as the uiviewcontroller view, it ignores the 64px of the navigationbar, making it bigger than the screen. Theres any way...

UIView animation happening immediately

ios,objective-c,animation,uiview
I have an animation of three buttons that used to work properly until I added different possible positions for the buttons. Now the animation happens immediately, but I'm not sure why. Here's some code: defaults=[NSUserDefaults standardUserDefaults]; _btnCuenta3.hidden=NO; CGPoint newPosition2; CGPoint newPosition3; CGPoint newPositionAgregar; if([defaults objectForKey:@"cuenta3"]){ newPosition2=CGPointMake(200.0f + _btnCuenta2.frame.size.width/2.0f, _btnCuenta2.center.y); newPosition3=CGPointMake(165.0f...

Frame in screen on UIView who is in UIScrollview

ios,uiview,uiscrollview
I would to know if there are an easy way to get the frame in the main screen of a UIView who is in a UIScrollview. Like - rectForRowAtIndexPath: in a UITableView....

how to display a UIView in a social media post

ios,facebook,swift,twitter,uiview
I don't even know if this is possible but I was wondering if there is anyway you can insert a UIView and all its contents into a tweet or facebook post so when the user sends out a tweet from the app, an image of the UIView is displayed in...

Make a UIView stick to bottom of the ViewController frame in Swift

ios,swift,uiview,cgrect
I have created a UIView (it's just a blue rectangle) and I want it to stick to the bottom of the frame/view of the screen. var nextBar = UIView() nextBar.backgroundColor = UIColor(red: 7/255, green: 152/255, blue: 253/255, alpha: 0.5) nextBar.frame = CGRect(x: 0, y: 600, width: self.view.frame.width, height: 50) self.view.addSubview(nextBar)...

Draw method of subclassed UIView (child of another subclassed UIView) not called

c#,ios,uiview,xamarin,monotouch
I have a subclassed parent UIView object which should add another subclassed UIView. This is the UIView I want to add and where the Draw method is not called: public class Circle : UIView { private UIColor color; public Circle () { this.color = UIColor.Black; this.BackgroundColor = UIColor.Clear; } public...