Menu
  • HOME
  • TAGS

Drawing Gradient with Core Graphic on UIImage result not consistent

ios,swift,uikit

You are essentially passing in an uninitialized block of memory for the color components. var colorComps = [startColorComp[0], endColorComp[0]] creates an array consisting of the first component of each color, so 2 components (not even the components you want) Further on, you pass that array of 2 elements in for:...

Can I repeat a label/button/variable name in different UIViews? (XCode)

xcode,swift,uiview,uikit

Variable with same name but in different class are perfectly fine and there are no side effects. So if you are declaring a button or any other ui element with same name in different class it is safe. Even if you are declaring outlets in UIViewControllers you are free to...

UIBezierPath circle get specific points

ios,uikit,core-graphics,uibezierpath

The equation for a circle is x = cx + r * cos(a) y = cy + r * sin(a) Where r is the radius, cx,cy the origin, and a the angle you can draw a circle with (UIBezierPath *)bezierPathWithArcCenter:(CGPoint)center radius:(CGFloat)radius startAngle:(CGFloat)startAngle endAngle:(CGFloat)endAngle clockwise:(BOOL)clockwise function by using a CGPoint as...

Theres is a way to be notified in swift if an UIImageView image has been set?

ios,swift,uiimageview,uikit

I did find the answer... Swift allows to override var so there is no real complication here. Just change where you use UIImageView to be using myUIImageView. class myUIImageView : UIImageView{ override var image: UIImage?{ didSet { if image != nil{ //do your stuff (add effects, layers, ...) } else...

Strange Bool type from UI control

ios,swift,types,uikit

A simple and satisfying rewrite is to cast: names.append(name: "whatever", important: importantSwitch.on as Bool) Even better, if you don't want to perform any casting or assignment dance, then use extend instead of append: names.extend([(name: "whatever", important: importantSwitch.on)]) As Martin R has said, a type alias also solves it, because it...

How does apple set the Delegates of the UIKit classes as Outlets?

delegates,uikit,protocols

Yes you will need to the IBOutlet keyword to the delegate property. Like: @property (nonatomic, assign) IBOutlet id <YourDelegateClass> delegate; ...

Delaying IBAction Button

ios,objective-c,cocoa-touch,uibutton,uikit

You should use NSUserDefaults. When save: method is called check current date [NSDate date] and save it into the user defaults. Then (when time has already passed) you retrieve the saved date from the defaults and compare it to the current date. If 23 hours have already passed you enable...

How change/create a new source type for UIImagePicker (SWIFT)

ios,xcode,swift,uikit,uiimagepickercontroller

//This class has UIButton when you click on button it opens PhotoPickersVC. Which will show all images from your application class ViewController: UIViewController,PhotoPickersDelegate { @IBOutlet var imageView:UIImageView! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } @IBAction func buttonBrowsePhotos(sender: UIButton)...

How can I know when any of the objects on screen were tapped?

ios,objective-c,uikit

You need to just subclass your main window, and you will find all touch events there. There is a handy catch-all method in UIWindow called sendEvent: which sees every event near the start of the event-handling pipeline. If you want to do any non-standard additional event handling, this is a...

How do you build an NSURL for an image in Image.xcassets?

ios,uiimageview,uiimage,uikit

While using xcasset, Xcode put all your files in a new one. 1 file to manage them all. So, you can't access to an image store inside an xcasset directly. From apple's documentation: For projects with a deployment target of at least iOS 7 or OS X 10.9, Xcode compiles...

iOS Swift: UITableViewCell editing set true after row deletion

ios,swift,uikit

Apparently deleting a row doesn't disable editing for that row. I added this line before deleteRowsAtIndexPaths which seems to do the trick: tableView.cellForRowAtIndexPath(indexPath)?.setEditing(false, animated: false) My understanding is that when I swipe on a cell I'm enabling editing for that cell. And because the next cell I insert is at...

How to reproduce this “offset behavior” programmatically?

ios,uikit,interface-builder

For UIScrollView and its subclasses (UICollectionView, UITableView), setting the contentInset to something like, say, UIEdgeInsetsMake(64.0 /* TOP */, 0.0 /* LEFT */, 44.0 /* BOTTOM */, 0.0 /* RIGHT */); would be the way to go. You can inspect the UIViewController's properties topLayoutGuide and bottomLayoutGuide to determine how much you...

iOS Keyboard Colour Changes - keyboardAppearance dark color doesn't stick

ios,cocoa-touch,uiview,keyboard,uikit

It may have todo with the fact that the keyboard is a global object. There's only ever one keyboard in memory at any given time. Also, the OS will automatically change the keyboard color based on the background. Therefore, your setting is probably just getting overridden. I would suggest hiding...

How could we possibly create this ui concept? [closed]

ios,user-interface,uikit,calayer,uibezierpath

You would do it exactly the way you just said - with a mask. A mask attached to a layer (or view) can make a hole through that view and its subviews. In this case, that hole is a circle. Here's an example: two UITextFields, in a view whose mask...

Implementing UIWebView inside UIScrollView

ios,iphone,uiwebview,uiscrollview,uikit

We already solved it in the comments, so let's just put this answer for completeness' sake. If you're using Auto Layout, make sure to change the size of the WebView by setting constraints such as a height constraint and changing its constant to make the layout change. If you want...

Child view controller does not auto layout when the parent UIViewController adjusts the size of the container view

ios,uiviewcontroller,uikit,rubymotion

When you add the child's view, you should give it constraints to make it the same size as the container view instead of setting its frame. If you do that, then it will automatically adjust when the container view's bounds change.

Matching the color of the 'transparent' navbar

ios,uikit,uinavigationbar

I'm looking at this same problem now and am using the layer inspector to look at the navigation bar. As it turns out, the UINavigationBar actually has two colored layers in it. One of them is based on your color, and one is a semitransparent near-white layer. Have a look...

Cannot display UIUserNotificationActions in foreground (default context)

ios,objective-c,uikit

For more than 2 buttons, the user has to select "Alerts" as opposed to "Banners" in the app settings menu. The alert will have an Options button that displays the buttons in a list between Open and Close. The Alert/Banner options cannot be set programmatically. If an app is in...

Preventing crash in UICollectionView

ios,uikit,uicollectionview

First of all, all UIKIT methods should be called on the main thread including reloadData. This though won't solve your crash. Secondly, somewhere in your code there is a race condition where you are calling reloadData and changing the data source simultaneously and you need to figure out where it...

how to make a specific fragment of an NSAttributedString a specific color in Swift

swift,uikit,uilabel

You already have this: let blueFont = UIFont(name: "HelveticaNeue-BoldItalic", size:14.0) myMutableString.addAttribute( NSFontAttributeName, value: blueFont!, range: myItalicizedRangeBlue) And this: let blueAttrs = [NSForegroundColorAttributeName : UIColor.blueColor()] So now just add another attribute: myMutableString.addAttributes( blueAttrs, range: myItalicizedRangeBlue) // or any desired range Or, combine the attributes first and add them together, if they...

Swizzling - Undo method selector swizzling in Objective-C iOS

ios,objective-c,uikit,selector,swizzling

I'm not familiar with CoconutKit, but swizzling is just a call to method_exchangeImplementations(). That function swaps two implementations. So if you call it again with the same parameters, you'll swap the implementations back. You'll need to look at how HLSSwizzleSelectorWithBlock_Begin builds up its call to method_exchangeImplementations() and make it again....

Using variables in CGRectMake, Swift, UIkit

ios,xcode,swift,uikit

CGRectMake takes CGFloats for all of its arguments. Your sample code should work fine if you specify that example is supposed to be a CGFloat, using a type identifier: // v~~~~ add this... var example: CGFloat = 100 Label1.frame = CGRectMake(20, 20, 50, example) Otherwise, swift infers the type of...

Constrain 2 Views using visual format language

objective-c,autolayout,uikit

Assuming you have two UIViews named view1 and view2 - [view1 addSubview:view2]; NSDictionary *views = @{@"view2" : view2}; NSArray *horzConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|[view2]|" options:0 metrics:nil views:views]; NSArray *vertConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[view2]|" options:0 metrics:nil views:views]; [view1 addConstraints:horzConstraints]; [view1 addConstraints:vertConstraints]; view2.translatesAutoresizingMaskIntoConstraints = NO; ...

What gets imported with UIKit, and how do I find out?

ios,objective-c,swift,uikit

Open your Swift source file. Find the import UIKit line. Command-click on the word UIKit. You'll see what UIKit imports: import Foundation import UIKit.NSAttributedString import UIKit.NSFileProviderExtension import UIKit.NSLayoutConstraint import UIKit.NSLayoutManager import UIKit.NSParagraphStyle import UIKit.NSShadow import UIKit.NSStringDrawing import UIKit.NSText import UIKit.NSTextAttachment import UIKit.NSTextContainer ... many more Command-click on the word Foundation...

Why dismissing view controller is not clearing presented controller from memory?

ios,cocoa-touch,swift,uikit

the timer is catching your view controller you should keep a weak reference to the timer, and add timer.invalidate() in dismissSelf https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSTimer_Class/index.html#//apple_ref/occ/instm/NSTimer/invalidate...

Cancel auto triggering value changed event for UISwitch

ios,swift,xamarin,uikit,uiswitch

You can just not add a target action for the .ValueChanged event. Just do the switching in you're background task completion handler. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), { println("This is run on the background queue") dispatch_async(dispatch_get_main_queue(), { aSwitch.value = true }) }) EDIT: Sorry, I just understood your question. You meant that the...

reloadRowsAtIndexPaths side effects?

ios,uitableview,cocoa-touch,uikit

You didSelectRowAtIndexPath will go with little bit changes like, - (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath]; bool isChecked = false; if ([currentValues[indexPath.row] boolValue]) { isChecked = false; currentValues[indexPath.row] = [NSInteger numberWithBool:false]; // below is the part of code that causes trouble [self.tableView deselectRowAtIndexPath:indexPath animated:NO]; //MYCHANGES [self.tableView...

How to tell the target interfaceOrientation in iOS 8?

ios,uiviewcontroller,ios8,uikit,uiinterfaceorientation

As you rightly say, you are receiving this event: - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator) The second parameter is a transition coordinator. Use it! It has a targetTransform property that tells you what's about to happen....

UITableViewAutomaticDimension not working until scroll

ios,uitableview,swift,uikit

I ran into the same issue and found out that the accessory cell.accessoryType messes with this automatic resizing when it is not None, so it seems like a bug at XCode at the moment. But as @Blankarsch mentioned, calling reloadSections(..) helps to fix this issue if you need to have...

UITableView second prototype cell does not appear to be respecting custom height?

ios,uitableview,cocoa-touch,storyboard,uikit

you need to implemented the table view delegate method heightForRowAtIndexPath: in order to change a cell's height. you can't do this purely in storyboards.

Swift: Change position of elements on storyboard through code

xcode,swift,storyboard,uikit

You can use outlets to modify constraints. Set constant property by code to modify the layout. ...

textField shouldChangeCharactersInRange is executing one step behind user action

ios,swift,uikit

The text hasn't changed yet when this method is called. You have to userange and replacementString to construct the email address, and then verify that.

Add constraint before view is seen?

ios,swift,autolayout,uikit,nslayoutconstraint

Try using viewDidLayoutSubViews, that might provide the timing you are looking for in this case.

Animating a UICollectionViewCell: Scroll To And Resize At The Same Time

animation,uikit,uicollectionview,uicollectionviewcell,uicollectionviewlayout

I learned that the best way to achieve an effect like this is to simply subclass UICollectionViewFlowLayout and tweak cell layout attributes based on the selected cell.

iOS Swift: Crash on deleteRowsAtIndexPaths

ios,swift,uikit,icloud,cloudkit

Before removing cells (or adding) you need to call beginUpdates() on the involved tableView. Then remove, or add cells. When finished, call endUpdates(). Once you call endUpdates(). Remember that once you call endUpdates() your tableView model must be consistent with the number of sections and rows you removed or added....

How to get currently active UIEvent?

objective-c,uikit

I solved this by listening for the notification in order to track the most recent UIEvent (I provided the UIEvent in the userInfo). Then, when receiving the notification again, I made sure that it is not the same event as the one that occured just before the custom view appeared...

UITableViewCell shadow

ios,xcode,uikit

The problem was in z position of UITableViewCell. Actually, it was displaying the top shadow too, but the upper cell had bigger z position so that top shadow was under it. I have just changed the z position of cell layer like this: selectedCell.layer.zPosition = 999; ...

iOS, Keyboard Predictive bar visibility

ios,uikit,uitextview,uikeyboard

Well you can handle when the user swipe to show/hide the bar(prediction bar) of UIKeyboard, First step declare a keyboard notification in viewdidLoad() and declare a global variable kbSize float kbSize; - (void)viewDidLoad { kbSize=0.0; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShowNotification:) name:UIKeyboardWillShowNotification object:nil]; --- rest of your code here--- } Second step...

Recognizing UIBarButtoItems with UIBarButtonSystemItemCancel at runtime?

ios,ios8,uikit,uibarbuttonitem

Why can't you just save a reference like UIBarButtonItem *myItem = [UIBarButtonItem initWithBarButtonSystemItem: UIBarButtonSystemItemCancel target: target action: action]; Then you can check via if(myItem != nil) {} But I guess I am not understanding your question correctly. Do you want to check whether the button is hidden or not ?...

Can't get UILabel's text to stay on multiple lines

ios,swift,uikit

Check that you're setting the auto layout constraints so you have the top, leading and trailing spaces defined, but don't hookup a vertical height, the label will adjust itself based on the content. Edit: ...

Should Interact With URL Changing Text View Color To Blue and Clickable

ios,objective-c,uikit

So I finally figured it out after a couple days, the solution was simply to use [myTextView setAttributedString: myAttributedString] instead of [myTextView setText: myString]. I'm guessing the automatic conversion to the text being blue and clickable is a bug in the UIKit, because I can't imagine why that would be...

WatchKit UIPageControl Dot Colour

ios,uikit,apple,uipagecontrol,watchkit

As written by an Apple Engineer in the Dev Forums, it's not possible to customize the color of the page control at this time. Source: https://devforums.apple.com/message/1100695#1100695...

Persistent UIToolbar in Swift

ios,swift,uikit,uitoolbar

UINavigationControllers feature an optional UIToolbar. Simply unhide it at the start of your first view controller (in viewDidLoad for example) to have it display throughout your app, ex: navigationController.toolbarHidden = false You can subsequently set your toolbar's items within each view controller by adding items to the view controller's toolbarItems...

How can I check if an appearance property has been set?

ios,objective-c,cocoa,uikit

You shouldn't need to make that check; the appearance system will take care of it for you. In your initialiser, set lineWidth to your default value using direct ivar access instead of its setter: _lineWidth = kDefaultLineWidth; If an appearance property has been set for lineWidth, this will be overridden....

Custom remote event handling in app from iOS lock screen

ios,objective-c,cocoa-touch,uikit,uiresponder

Maybe that is implemented with MPRemoteCommandCenter. Here is example... MPRemoteCommandCenter *remoteCommandCenter = [MPRemoteCommandCenter sharedCommandCenter]; [[remoteCommandCenter skipForwardCommand] addTarget:self action:@selector(skipForward)]; [[remoteCommandCenter togglePlayPauseCommand] addTarget:self action:@selector(togglePlayPause)]; [[remoteCommandCenter pauseCommand] addTarget:self action:@selector(pause)]; [[remoteCommandCenter likeCommand] addTarget:self action:@selector(like)]; Implement this code, play music on...

NSSearchPathForDirectoriesInDomains working on simulator but not on device

ios,swift,uikit

You just forgot to add "/" between the folder and the file's name: let sketchPath: String = "\(destinationFolder)/\(currentProjectID).png" You should use stringByAppendingPathComponent and stringByAppendingPathExtension: let currentProjectID = "Test" // you can also use NSFileManager's method URLsForDirectory to find the device's DocumentDirectory let destinationFolder = (NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask).first as NSURL).path! let...

UISearchController disable cancel UIBarButtonItem

ios,objective-c,uikit,uisearchbar,uisearchcontroller

Updated in light of comments UISearchBar has a property (see the Apple docs) which determines whether the cancel button is displayed: self.searchBar.showsCancelButton = false; But, as per OP comments, this does not work, because the searchController keeps switching the cancel button back on. To avoid this, create a subclass of...

alpha for background color not working in iOS

ios,iphone,xcode,swift,uikit

If you are using storyboard and present view controller using segue, the presentation attribute of segue that show you view controller with transparent background should be over full screen as shown in attachment. Then in your view controller set the background color by using this : self.view.backgroundColor = UIColor(white: 0,...

Size UIView to UIViewController's view programmatically

swift,storyboard,uikit,autolayout

Generally, when adding a view in IB, it's easier to add the constraint in IB, too. Then you simply don't have to deal with all the issues I'll enumerate below. But, if you're determined to create views in IB but add constraints programmatically, you should note: In Xcode 6, if...

Why am I unable to save my UIFontDescriptor into a variable?

objective-c,ios7,uikit,uifont,uifontdescriptor

Initially, I counted 4 open brackets and 3 close brackets, which will cause an error. Additionally, fontWithDescriptor: should be fontWithDescriptor:size:, which is probably the expected expression. Finally, using fontWithDescriptor:size: to define a font, then asking for its descriptor is redundant, so a cleaner version of the command is this: UIFontDescriptor...

how to indent a space between image and text in UITextField

ios,objective-c,cocoa-touch,uitextfield,uikit

If you talk about leftView and rightView, you can create subclass of UITextField and override follow methods: - (CGRect)leftViewRectForBounds:(CGRect)bounds; - (CGRect)rightViewRectForBounds:(CGRect)bounds; ...

app-specific UIPasteboard

ios,objective-c,cocoa-touch,uikit,uipasteboard

Please read this article http://nshipster.com/uimenucontroller/ (It's about UILabel, not UITextField but is useful just for example and information about how copy/paste/edit actions work and how you can customize its' behavior) I think you need to subclass UITextField to MyTextField for example, and override -(void)copy: and -(void)paste: methods from UIResponderStandardEditActions. In...

Efficiently convert an area to matrix in Sprite Kit

ios,objective-c,matrix,sprite-kit,uikit

You should create object and give it properties column, row. This is my algorithm of creating puzzle game something like Candy crush :D -(void)createRandomly { for (int row = 0; row < rows; row++) { for (int col = 0; col < columns; col++) { float dimension = self.frame.size.width /...

MPVolumeView animation issue

ios,objective-c,uikit,mpvolumeview

One possible way to remove this behavior is to subclass MPVolumeView and perform some additional work after [super layoutSubviews]. - (void)layoutSubviews { [super layoutSubviews]; [self xy_recursiveRemoveAnimationsOnView:self]; } - (void)xy_recursiveRemoveAnimationsOnView:(UIView *)view { [view.layer removeAllAnimations]; for (UIView *subview in view.subviews) { [self xy_recursiveRemoveAnimationsOnView:subview]; } } This removes all inserted animations. So be...

fill UIBezierPath but keep path clear

objective-c,uikit,uibezierpath

If what you are trying to do is erase everything within the thick outline of a path, use CGContextReplacePathWithStrokedPath to convert the stroke to a path. Then fill it with a clear blend mode, thus erasing the drawing along the thick path. Alternatively, just stroke the path, again using a...

Odd behaviour with UITableViewCell when scrolling, UIButtons disappearing

ios,objective-c,xcode,uitableview,uikit

You can try by unhiding the button and Label in your first conduction like: if ((int)indexPath.row * 4 + i < [self.currentUser.friends count]) { [button setEnabled:YES]; [button setHidden:NO]; [label setHidden:NO]; // Other code } else{ ...... } ...

How do I prevent my UISplitViewController from displaying the master VC when rotating to portrait?

ios,uikit,autolayout,uisplitviewcontroller,size-classes

It is typical of me to solve my issues 5 minutes after asking them on SO. Turns out the splitViewController:collapseSecondaryViewController:ontoPrimaryViewController UISplitViewController delegate method is in charge of choosing the "collapse" of the views. What originally threw me off is that I didn't consider going back to portrait as something that...

How do I toggle hidden of a label while a button is pressed?

ios,uibutton,uikit,uilabel

The UIButton class, as well as lots of other UIControl subclasses can have numerous actions hooked up to them. When we are hooking up an action from interface builder to our source code file, if we open the "Event" drop down, we're presented with a long list of options: In...

Swift Delegate not Being Called

ios,swift,uikit

Declaring GameController as NumpadPressDelegateProtocol is not enough for you to get a callback. You also need to set the pressDelegate of the NumpadView instance inside the Gamecontroller. Assuming numpadView is the instance variable be it IBOutlet or not, you have to set the delegate like Inside GameController init numpadView.pressDelegate =...

Issue with a UINavigationController inside a UITabBarController inside another UINavigationController

ios,cocoa-touch,uinavigationcontroller,uikit,uitabbarcontroller

I wouldn't recommend using a UINavigationController to segue from your login to your main UITabBarController... personally, I prefer to have a different rootViewController of the main UIWindow as a login or presenting the login modally (without animation)... this makes more sense, since you don't expect a user to "navigate back"...

Typhoon inject xib loaded table cells

ios,objective-c,uikit,typhoon

Probably the easiest thing to do would be to create a view assembly for your xib loaded table cells, and make this one of your application assemblies. Assuming you're using plist integration then you'd add it to your app's plist as: <key>TyphoonInitialAssemblies</key> <array> <string>ViewProvider</string> <string>ApplicationAssembly</string> <string>CoreComponentsAssembly</string> <string>NetworkAssembly</string> </array> Logically it...

NSLayoutConstraint constraintWithItem… ordering

ios,uikit,autolayout,nslayoutconstraint

Apple's Programming Guide provides the answer: https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/AutoLayoutConcepts/AutoLayoutConcepts.html#//apple_ref/doc/uid/TP40010853-CH14-SW1 Specifically, constraints represent this equation: y = m*x + b. Where 'x' and 'y' are views attributes, 'b' is the constant, and 'm' is the multiplier. 'x' and 'y' map to the first and second items in the method you're calling, respectively. So...

iOS: Loading second view controller without nib file

ios,objective-c,uiviewcontroller,uikit,xib

The right method is the following: [self presentViewController:vc2 animated: YES completion:nil]; ...

Supporting @3x, @2x Tab bar icons with PaintCode 2 StyleKit

ios,storyboard,uikit,paint-code

Yes, set the canvas size to 25×25 points. You can then preview the canvas at @1x, @2x or @3x (or infinite) scale. When you ask the StyleKit for image of this canvas, the returned UIImage will have the size of 25×25 points, but scale of the current screen. That means...

Animate Images with completion handler in Swift

swift,animation,uikit

completion handler does not seem to be recognizing the end of the animation UIImageView image animation doesn't have a "completion handler". It is much more simple-minded than that. If you want a completion handler, use some sort of animation that does have a completion handler. (In your case, I...

How do I make DTCoreText use the System Font?

ios,objective-c,uikit,nsattributedstring,dtcoretext

Looks like DCCoreText is expecting to receive font family name, and you're providing font name which is different. Try to replace your code with [UIFont systemFontOfSize:[UIFont systemFontSize]].familyName ...

Why UIButton.addTarget needs a “:” after the string representing the action?

ios,iphone,cocoa-touch,swift,uikit

It comes from Objective-C. Basically it means that the action method takes a parameter. In your case the parameter passed will be the sender (i.e. the UIButton that generated the action to be called.

Label on UIButton not laid out correctly with autolayout

ios8,uibutton,autolayout,uikit,uistoryboard

Ok, this was a real school boy error. When the docs said 'The implementation of this method is empty before iOS 6' I for some reason took this to mean there's no need to call super on layoutSubviews. So the fix was: -(void) layoutSubviews { [super layoutSubviews]; // <<<<< THIS...

What should be mentioned as “Front-end” of my simple iOS Application?

ios,objective-c,cocoa-touch,uikit,frontend

Cocoa Touch Framework would suffice, as it also encapsulates UIKit https://developer.apple.com/technologies/ios/cocoa-touch.html Edit: to eliminate your other thoughts, iOS is the operating system for the phone, and Objective-C is the language. What you're looking for is describing the frameworks you are using for your project-- i.e Cocoa Touch works perfectly....

Reuse a function across multiple UIViewControllers

ios,swift,uikit

You have to declare it outside of the class-body: import UIKit import SpriteKit class OneClass{ func notGlobal(){ println("not global") } func globalMethod(string:String){ println("its global") } ...

Losing tap recognition after adding a UIScrollView under a UIButton

ios,uiscrollview,uibutton,uikit,uitapgesturerecognizer

I would suggest that the button is not being placed above the right scroll view properly. I know you've set the zPosition, however you should try bringing the button to the front (and sending the two scroll views to the back) using: [self.view bringSubviewToFront:button]; [self.view sendSubviewToBack:scrollView1]; [self.view sendSubviewToBack:scrollView2]; If the...

How do you put a UIKit into an iOS app?

ios,uikit

So a friend of yours is doing the design and you are doing the coding. (UIKit is a different thing indeed). I am usually starting with wireframes. From a wireframe you can actually implement a fully working app with all functionality. But that's my preference as you can work in...

Getting error when adding constraint

ios,objective-c,autolayout,uikit,nslayoutconstraint

The addConstraint: method expect a single constraint, however the constraintsWithVisualFormat: returns an NSArray of zero or more constraints. Try adding an s. [self addConstraints:/*your NSLayoutConstraint constraintsWithVisualFormat: call */]; Apple's naming conventions can usually help you out here. Notice that constraintsWithVisualFormat is plural while addConstraint: was singular (and addConstraints: is plural)....

UIButton border disappears

ios,uikit,interface-builder

You can not set some properties of a view's layer through interface builder. You can set a layer's borderWidth and cornerRadius via Interface Builder tool of Xcode, but you will not be able to set borderColor using Interface Builder and it's probably because the layer.borderColor wants a CGColor instead of...

UIButton causes (lldb) error with EXC_BAD_ACCESS

ios,swift,uibutton,uikit

Edit: It looks like init is a special keyword Swift uses when bridging ObjC code. From the docs: Initialization To instantiate an Objective-C class in Swift, you call one of its initializers with Swift syntax. When Objective-C init methods come over to Swift, they take on native Swift initializer syntax....

UICollectionView cells overlapping swift

ios,swift,uikit,uicollectionview

You shouldn't assign the frame value by yourself in the cellForItemAtIndexPath method. The more suitably way is to do this in the UICollectionViewLayout, then set it as the collectionview's layout property. Actually, you need a UICollectionViewLayout instance when you init the UICollectionView instance. Or simply, use the UICollectionViewFlowLayout which system...

Best way to switch UIViewControllers based on different input in an ios application

ios,swift,uiviewcontroller,uikit,xcode-storyboard

In case anyone cares, the way that I solved this problems was by creating segues from main view controller itself and naming the segues with an identifier. Then, based on the position of the UISegmentedControl I called the segue with the identifier with the method self.performSegueWithIdentifier(<String Identifier>, sender: self).

How come UIKit doesn't have UIMatrix, UIButtonCell class like AppKit's NSMatrix, NSButtonCell?

uikit

The equivalent in iOS is UICollectionView. It's much more flexible and useful than NSMatrix, here a tutorial.

Thread safety when returning static variables

ios,objective-c,thread-safety,uikit

You could make a million concurrent calls to primaryColor and not have an issue (other than too many threads :) ). It's a read-only method. The only possible concern is if primaryColor is called at the same time as configureColors. And that's not a problem since you are calling configureColors...

iOS 8 UITabBar selectionIndicatorImage leaves rounded rectangle

ios,uikit,uitabbarcontroller,uitabbar

Button shapes is most likely on in Settings, under General>Accessibility. Changing it to foobar fixes it because it sets the selected one to a tab that doesn't exist, therefore making button shape think that it is that instead of the original view controller....

UITableViewCell auto-sizing height not working

ios,objective-c,uitableview,uikit

Try to set the properties of table : tableView.estimatedRowHeight = 44.0; tableView.rowHeight = UITableViewAutomaticDimension; If content change then use notification to reload the table - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(contentSizeCategoryChanged:) name:UIContentSizeCategoryDidChangeNotification object:nil]; } - (void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; [[NSNotificationCenter defaultCenter]...

How do I mix UIKit and SpriteKit?

ios,swift,uikit,sprite-kit

I would highly recommend you to stick with SpriteKit and to create menus etc with SKNodes. I know that it is really seductive to use UIKit in a game for buttons etc. but you've got many possibilities right in SpriteKit which replaces UIKit-elements. For example you can use an SKLabelNode...

String with `\(var)` causes “unwrapping an optional value” error

ios,uitableview,swift,uikit

In Xcode, option-click on each of the variables in use: urlString, peopleArray and theTable. The popup that appears will show you whether the variable is an optional variable by appending a ? to the class name. From your code above, urlString should not be an optional and therefore should not...

UIScrollView “out of frame” touch areas don't respond

ios,objective-c,iphone,uiscrollview,uikit

According to the information you provided, you are shifting the entire view.frame by 152 pts upwards, but the size of the view remains the same. You should also increase it's height by 152 pts. That happens because the portion of the scrollView that is hidden, is still being drawn outside...

How to share multiple urls via UIActivityViewController?

ios,objective-c,cocoa-touch,uikit,uiactivityviewcontroller

There is nothing you can do to change the standard Facebook and Twitter sharing extensions. Now that iOS 8 allows us to make custom extensions, we can see that these extensions decide for themselves which items they can handle. Apple's Extension programming guide discusses how an extension can specify which...

App crashes when setting a class to UITapGestureRecognizer's target instead of 'self'

ios,swift,uikit,uitapgesturerecognizer,ios8.1

It crashes because target is a weak property of the UITapGestureRecognizer class and so the instance of SkinViewTransitionHelper is not retained by by the UITapGestureRecognizer. Make a property of type SKinViewTransitionHelper and store an instance on it and set it to the UITapGestureRecognizer target. class LaunchView { var skinViewHelper :...

How can I easily move containers with swift

uikit

It is very easy actually. In IB create your top, bottom, left and right constraints with heights as well. And then ctrl drag the top constraint with connects the top view to the top of the superview. Go to your class and just give the desired constant value as you...

Multicolored UISlider, is it possible?

ios,uikit,uislider

You can do this without adding/managing your own subviews, but you will need custom images. You can use the setMinimumTrackImage:forState and setMaximumTrackImage:forState which are built in properties of the UISlider API. The minimum image will show from the minimum end of the slider to the thumb image, and the maximum...

iOS Notification Center Registration

ios,objective-c,notifications,uikit,apple-push-notifications

Take this as an example: [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]]; [[UIApplication sharedApplication] registerForRemoteNotifications]; ...

UIAlertView wont delegate

objective-c,cocoa-touch,uikit

I think your question is missing some important details that are causing the issue, so answer comes from speculating on the last comment you made. You need to have all your view controllers implement the alert view delegate that will be presenting a UIAlertView. It sounds like you implement the...

Add subview to current view's UINavigationBar only

ios,objective-c,iphone,swift,uikit

This is happening for a few reasons: Adding a subview to a UINavigationBar isn't exactly unsupported, but could possibly result in odd behavior. All view controllers in a UINavigationController share the same UINavigationBar (which is why a newly pushed view controller didn't have any affect on your subview). If you...