FAQ Database Discussion Community


Recognizing UIBarButtoItems with UIBarButtonSystemItemCancel at runtime?

ios,ios8,uikit,uibarbuttonitem
I would like to check for the presence of a UIBarButtonItem that was initialized like this: [UIBarButtonItem initWithBarButtonSystemItem: UIBarButtonSystemItemCancel target: target action: action]; How can this be done? It's title is apparently nil and UIBarButtonItem does not expose systemItem?...

Add subview to current view's UINavigationBar only

ios,objective-c,iphone,swift,uikit
What I want to do is add a custom view to my UINavigationController's UINavigationBar but only for the current visible view controller. So I build the subviews of the view I want to add in a container view and this view to the navigation bar by getting a reference with:...

Typhoon inject xib loaded table cells

ios,objective-c,uikit,typhoon
I’m trying to migrate some of my view controllers and UITableView subclasses over to using Typhoon, but I can’t find any documentation around what to do with cells that are generated from a tableView’s dequeReusableCellWithIdentifier. The TableViewController I’m working with uses multiple cell types which it registers with the TableView...

UISearchController disable cancel UIBarButtonItem

ios,objective-c,uikit,uisearchbar,uisearchcontroller
The Problem I am trying to use UISearchController to search for a destination on a map view. I want the UISearchBar to appear in the navigation bar, but I can't seem to make it do so without it showing a cancel button to the right of it: This Cancel button...

Efficiently convert an area to matrix in Sprite Kit

ios,objective-c,matrix,sprite-kit,uikit
I am new to Sprite Kit. I am looking for a way to convert an area to a matrix, and put objects inside the matrix. Let us assume, I have a *SKSpriteNode matrix of size 100 x 100 i.e height and width both 100.I want to turn it to a...

Size UIView to UIViewController's view programmatically

swift,storyboard,uikit,autolayout
I'm trying to size a UIView to its superview. This works, except in the view that is automatically given in a Storyboard. So this code works for the subview2 but the subview is not sized to its enclosing view. import UIKit extension UIView { func addConstraintsWithVFL(constraintsVFL: String, views: [String: UIView],...

iOS Notification Center Registration

ios,objective-c,notifications,uikit,apple-push-notifications
I want to make a game that tests out local notifications. In iOS 8, the code involves these steps: Make a UIMutableUserNotificationCategory object that is the category of custom actions you want to implement. Make up to 4 custom actions by using UIMutableUserNotificationAction instances. Call setActions:forContext: to set up custom...

Constrain 2 Views using visual format language

objective-c,autolayout,uikit
I got two views and i want that view1 has a top, bottom, trailing and leading space of zero to view2. How can i realize that using the visual format language ? I know that i have to create a dictionary that assigns a string to a view and then...

Using variables in CGRectMake, Swift, UIkit

ios,xcode,swift,uikit
For an App I'm making i need to use variables to change the size and position of objects (Labels). I've tried var example = CGRectMake(0, 0, 0, 100), hoping it would ignore the zeros (Not really thinking it would though). I then tried: var example = 100 Label1.frame = CGRectMake(20,...

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

ios,uiimageview,uiimage,uikit
The easiest way to load a local UIImage asset is of course to use +[UIImage imageNamed] but for my case, I want to supply a NSURL *. How do I get a NSURL * for local file?

Add constraint before view is seen?

ios,swift,autolayout,uikit,nslayoutconstraint
I am trying to center an arrow button with a width = 40 in the middle of my screen using constraints programmatically. My code works if I call it in viewDidAppear but crashes in viewDidLoad. Having it in viewDidAppear is an eye sore since you see the screen and then...

iOS 8 UITabBar selectionIndicatorImage leaves rounded rectangle

ios,uikit,uitabbarcontroller,uitabbar
I am creating a sample "Tabbed Application project" with Xcode 6.3. The tab bar is configured in the Storyboard view, and its configuration is set thus: As you can see, the Selection part is set to an empty string, which is the default value. However, when running the app in...

Swizzling - Undo method selector swizzling in Objective-C iOS

ios,objective-c,uikit,selector,swizzling
We're making use of Swizzling in Objective-C. For convenience we're using CoconutKit's helper methods to achieve this: HLSSwizzleSelectorWithBlock_Begin([TMObjectCache class], @selector(objectForKey:)) ^(TMObjectCache *self, NSString *key) { key = nil; return ((id (*)(id, SEL, NSString*))_imp)(self, _cmd, key); } HLSSwizzleSelectorWithBlock_End; We'd like to however also un-swizzle this method after some point in the...

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

objective-c,ios7,uikit,uifont,uifontdescriptor
I have the following code: UIFontDescriptor *fd = [UIFont fontWithDescriptor:[[UIFont systemFontOfSize:[UIFont systemFontSize]].fontDescriptor fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitBold|UIFontDescriptorTraitItalic]; But it gives me the error "Expected expression". What does that mean?...

UIButton border disappears

ios,uikit,interface-builder
I'm designing a new button for an app, I'd like to avoid coding as I have to use the same button style through the app. I added some attributes and it works fine, but when I add a border color (doesn't matter which color) for no reason the border disappears....

How to reproduce this “offset behavior” programmatically?

ios,uikit,interface-builder
Since iOS 7, Apple encourages developers to show content behind navigation bars and other translucent elements. Let's say that I have a view controller embedded in a navigation view, adding to this view controller a map view and extending the edges of the map view to the bounds of the...

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

ios,objective-c,cocoa-touch,uikit,frontend
For example, suppose I created a simple iOS project that get data from server using NSURLRequest and store using CoreData. Is Front-end should be marked as Cocoa Touch or iOS or Objective-C or UIKit Framework or something else ? I am desperate to the term I should use while mentioning...

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

xcode,swift,uiview,uikit
So I'm working on an XCode project using Swift and I'm wondering if using the same name for (for example) different buttons in different views causes any bugs. Same with variables, labels, etc. -Thanks...

UISwipeGestureRecognizer over UIButtons

ios,cocoa-touch,uibutton,uikit,uigesturerecognizer
I want swipes to be detected on the lower half of the screen. That part of the screen can have UIButtons as well. I want the swipes to take priority over the buttons (that is, if you swipe over the buttons, the buttons are ignored). But I want the buttons...

app-specific UIPasteboard

ios,objective-c,cocoa-touch,uikit,uipasteboard
I'm trying to create app-specific UIPasteboard, but have some problems figuring out how to register it: UIPasteboard *pasteboard = [UIPasteboard pasteboardWithName:@"myPasteboard" create:YES]; If I just create it, app continues to use generalPasteboard. I really hope that I don't have to catch cut/copy/paste operations and set items manually....

how to indent a space between image and text in UITextField

ios,objective-c,cocoa-touch,uitextfield,uikit
I am trying to add a space between the text that user is going to type and an UIImage in a text field . Can any one please help me .

How to get currently active UIEvent?

objective-c,uikit
Background I have a custom UIWindow implementation that posts a notification in the sendEvent method. Then I have a custom view that, once added to the window hierarchy, removes itself from superview as soon as the mentioned notification is posted (i.e. tapping anywhere, in this view or not, removes the...

Swift: Change position of elements on storyboard through code

xcode,swift,storyboard,uikit
Probably a very trivial Swift question. I've got a view on my storyboard with various UIelements (labels, images etc). What I want to do is change the position of some of these elements through code (so not using the storyboard or autolayout features). When I create my elements dynamically I...

Animate Images with completion handler in Swift

swift,animation,uikit
Animation is working, however completion handler does not seem to be recognizing the end of the animation. I would like to call that println after the animation has completed. How can I best achieve that? var vaultClosedImage = UIImageView(image: UIImage(named: "vaultClosedAlpha.png")) override func animationDidStop(anim: CAAnimation!, finished flag: Bool) { if...

Cancel auto triggering value changed event for UISwitch

ios,swift,xamarin,uikit,uiswitch
Is it possible to cancel auto triggering value changed event for UISwitch? I have action of touch up inside event for the UISwitch, I wanna do background job first and then when job is done, i manually turn the switch on instead of it turns itself on immediately after touch...

Label on UIButton not laid out correctly with autolayout

ios8,uibutton,autolayout,uikit,uistoryboard
I have an app which I'm updating to auto layout and size classes and I'm getting some weird behaviour with the label on a button. The button should be a circle and have a label in the centre. I'm implementing my own subclass so I can reuse it. Here's the...

How do you put a UIKit into an iOS app?

ios,uikit
I'm a newbie iOS developer. I'm getting a UIKit designed by an independent designer. How do I take his photoshop design and put it in my app? Do I code the app first and then put the design in? What's the best way to do it?...

Preventing crash in UICollectionView

ios,uikit,uicollectionview
Our app has UICollectionView and its dataSource dictionary is regularly updated. We never know when next update will happen. Collection View reload method could be called after user taps a button or it could happen asynchronous after network request success. Given above information we have the risk to have a...

How do I mix UIKit and SpriteKit?

ios,swift,uikit,sprite-kit
I am making a game in Swift. I have used both UIKit and SpriteKit, but never in the same app. I was wondering how to leverage the power of both of them (They are going to be a lot of menus). If you knew a tutorial I could use, or...

Matching the color of the 'transparent' navbar

ios,uikit,uinavigationbar
I have a navbar that is set to translucent. I do not want to change this. I set the bar tint color on the navbar and it looks great. However the color I set is not the 'true' color that is displayed since I have translucent set to 'YES'. I...

Losing tap recognition after adding a UIScrollView under a UIButton

ios,uiscrollview,uibutton,uikit,uitapgesturerecognizer
I have two adjacent UIScrollViews, both partially covered by a UIButton with a tap gesture recognizer. They are added to the view in this order: Scrollview #1 Button Scrollview #2 (added by user interaction) Both scrollviews are z-positioned "behind" the button, but the button does not receive taps where it...

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

ios,objective-c,iphone,uiscrollview,uikit
I'm creating a UIScrollView as say (320, 320), at origin (0, 400). Assuming for now I'm designing for an iPhone 5S, with 568pts of height. This means the bottom portion of my scrollView does not appear in the ViewController's view as its too tall. Later, I shift my entire ViewController...

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

uikit
I find AppKit's NSMatrix and NSButtonCell classes useful for grids of buttons. I wonder why Apple never created these counterparts for UIKit?

Odd behaviour with UITableViewCell when scrolling, UIButtons disappearing

ios,objective-c,xcode,uitableview,uikit
I am trying to set up some UIButtons and UILabels in my custom UITableViewCell. For each row in the table I have 4 buttons with user profile images and below each button is a label displaying the username. Images and usernames are taken from Parse.com. I have a friends array...

UIButton causes (lldb) error with EXC_BAD_ACCESS

ios,swift,uibutton,uikit
I've seen this issue many times on SO, but the solutions to those questions have not fixed my issue. I dynamically create a UIButton and add it to my view. I add a target to the button, which is a function. The target functions runs (i.e. the print statement runs),...

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

ios,objective-c,uikit
I have a table view of posts, all of which contain URLs in their text bodies, and whenever I interact with the initial URL through: - (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL*)URL inRange:(NSRange)characterRange { //present webview here return NO; } After I dismiss the modal view controller displaying the web view, the entire...

alpha for background color not working in iOS

ios,iphone,xcode,swift,uikit
Do you have any idea why alpha parameter does not work on my view ? self.view.backgroundColor = UIColor.blackColor().colorWithAlphaComponent(0.4) please also check this video Video thanks ...

Change the parent of a view

ios,swift,uikit
I have a table view that i would display at some point after I get some results from the database @IBOutlet weak var resultSetView: UITableView! I this table view is already made in the ViewController I would like to put this element in another view like a dock view maybe...

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

ios,xcode,swift,uikit,uiimagepickercontroller
I am new in iOS development and I need help. I use UIImagePicker so that the user selects his image. I want that user selects pictures located in a folder of the application and not the iOS library. All this using UIImagePicker. Is this possible? If I am wrong please...

Issue with a UINavigationController inside a UITabBarController inside another UINavigationController

ios,cocoa-touch,uinavigationcontroller,uikit,uitabbarcontroller
Don't ask me to show the code because there's no code. Everything has been done in a storyboard. My app starts with a main navigation controller which holds a login view controller as its root view controller. The login view controller has a button. When the button is pressed a...

UICollectionView cells overlapping swift

ios,swift,uikit,uicollectionview
I am creating a UICollectionView, but when a new cell is added to the view it is partially overlapping the previous cell. Below is my code: override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCellWithReuseIdentifier("CustomCell", forIndexPath: indexPath) as! CustomCell cell.frame.size.width = self.view.frame.width / 3 cell.frame.size.height...

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

swift,uikit,uilabel
I have a UILabel with an NSAttributedString with the following code: // just creating from a notification.mainCopy! var myMutableString = NSMutableAttributedString(); myMutableString = NSMutableAttributedString(string: notification.mainCopy!, attributes: [NSFontAttributeName:UIFont(name: "Helvetica", size: 14.0)!]) // a notification will have a blueMainCopy1 - just a test so no this could be done better // How...

iOS: Loading second view controller without nib file

ios,objective-c,uiviewcontroller,uikit,xib
I have a project, which consists of the standard AppDelegate and ViewController files, but does not utilize nib files. Here's the code: delegate header // AppDelegate.h #import <UIKit/UIKit.h> @class ViewController; @interface AppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @property (strong, nonatomic) ViewController *vc1; @end delegate implementation // AppDelegate.m...

UIBezierPath circle get specific points

ios,uikit,core-graphics,uibezierpath
I would like to draw one big circle and place some smaller circles as shown in the image below I draw the big circe in - (void)drawRect:(CGRect)rect CGFloat rectX = self.frame.size.width / 2; CGFloat rectY = self.frame.size.height / 2; CGFloat width = self.frame.size.width-30; CGFloat height = self.frame.size.width -30; CGFloat centerX...

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

ios,iphone,cocoa-touch,swift,uikit
I have the following code: button.addTarget(self, action: "buttonIsPressed:", forControlEvents: .TouchDown) Why do I need the ":" after the string for action?...

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

ios,user-interface,uikit,calayer,uibezierpath
I came across this UI Concept, I couldnt help but to admire it's beauty. I am wondering if it is possible to create a Button that makes (mask) the control below them, to make them look transparent in that area. (In this case UITextField) Please take a look at this...

NSLayoutConstraint constraintWithItem… ordering

ios,uikit,autolayout,nslayoutconstraint
Whenever I create an NSLayoutConstraint via +constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:, I always seem to end up putting the items in the wrong order, and then I have to reverse them. It is so annoying, and I can't seem to figure out any way to be able to tell before actually running the code...

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

ios,uitableview,cocoa-touch,storyboard,uikit
I am dequeuing the second prototype cell but the height of the cell appears to not be respected. Can anyone lead me in the right direction ? I have tried searching google with no avail. The problem has been solved,my solution is implementing in code: -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {...

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

ios,cocoa-touch,swift,uikit
I have 2 controllers. Each of them have only one button on screen. For first controller button is presenting modally second controller, and for second controller button is dismissing presented controller. Code of first one is simple as door: class ViewController: UIViewController { @IBAction func present(sender: AnyObject) { let storyboard...

Custom remote event handling in app from iOS lock screen

ios,objective-c,cocoa-touch,uikit,uiresponder
How does spotify handle custom remote events? Currently on iPhone 6 running iOS 8.1.3 and spotify version 2.4.0.1822 I get the following controls on the lock screen when I turn on spotify radio. Ive tried reading all docs pertaining to remote events, and I'm unable to find any resources which...

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

ios,swift,uikit
I have a UILabel that should display text on multiple lines in case that it's too long to stay on a single line. This how I set its parameters in interface builder: But even by doing so, the text still gets truncated: This is how I set the text at...

Display fractions of pixels in UIKit for smooth slow motion

ios,cocoa-touch,uikit
I have a view which move down with a very slow constant speed. var updater = CADisplayLink(target: self, selector: Selector("loop")) func loop() { view.center = CGPointMake(view.center.x, view.center.y + 0.01) } loop is called 60 times in a second and move view 0.01 point down. 0.50 point is pixel on retina....

NSSearchPathForDirectoriesInDomains working on simulator but not on device

ios,swift,uikit
I'm trying to save, and later load, an image from disk. The following works on the simulator, but when I test on the device, I get unexpectedly found nil while unwrapping an Optional value. Saving image to disk: let sketchData: NSData = UIImagePNGRepresentation(sketch) let destinationFolder: String = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0]...

Drawing Gradient with Core Graphic on UIImage result not consistent

ios,swift,uikit
Objective I am trying to draw a linear gradient on top of an image. Setup I have an function call imageWithGradient which takes the colors and the imageView to put the image with gradient drawn on in. I added the imageView to the view using storyboard. Problem When I try...

iOS Swift: UITableViewCell editing set true after row deletion

ios,swift,uikit
After deleting a row in a UITableView the next row I create has editing set to true. I'm not sure why this is, but what it means is that after I delete a row, the next row that I create is indented on the left side by about 40 points....

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

ios,swift,uikit,uitapgesturerecognizer,ios8.1
The below code works when I set 'self' as target to the instance of UITapGestureRecognizer but when I set it to 'SkinViewTransitionHelper' instance the app crashes and the Xcode doesn't show any helpful information, actually nothing at all and when the app crashes the control(the green indicator I mean) goes...

How can I easily move containers with swift

uikit
I have 4 containers and need to move them up 40 pixels together. Can i move all of them at once. I have tried changing the rect of them one by one, but when rotation occurs everything is messed up....

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

ios,uibutton,uikit,uilabel
I am trying to figure out how to only display a label while a button is pressed in OS. I know how to operate the touch events but I am not sure how to incorporate the UILongPressGestureRecognizer into this.

Getting error when adding constraint

ios,objective-c,autolayout,uikit,nslayoutconstraint
I'm trying to set a constraint on 2 views so that they touch each other like this: I tried setting constraints programmatically: [self addConstraint:[NSLayoutConstraint constraintsWithVisualFormat:@"[_firstView][_secondView]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_firstView, _secondView)]]; But I get the following warning: Incompatible pointer types sending 'NSArray *' to parameter of type 'NSLayoutConstraint' What am I doing...

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

delegates,uikit,protocols
I've been trying to find a way to set the delegates on my custom classes as Outlets so I can connect them via IB just like one does with an UIKit Class but I haven't been able to do this, is this even possible?

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

animation,uikit,uicollectionview,uicollectionviewcell,uicollectionviewlayout
I'm trying to get a UICollectionViewCell to do an animated resize and at the same time have the collection view scroll the cell to the top of the collection view's viewport. When I do - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { [self.collectionView scrollToItemAtIndexPath:indexPath atScrollPosition:UICollectionViewScrollPositionTop animated:YES]; [collectionView performBatchUpdates:nil completion:nil]; } with -...

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

ios,swift,uiimageview,uikit
if UIImageView were my class I would have solved this by doing: class myUIImageView{ var image : UIImage? { didSet { if self.image != nil{ //do my stuff } } } //Other fields and functions } What I want is to be notified (Observer Like) ...

How do I make DTCoreText use the System Font?

ios,objective-c,uikit,nsattributedstring,dtcoretext
I want to use DTCoreText in my app to convert HTML to NSAttributedString, but I can't figure out how to use the system font (as of iOS 8: Helvetica Neue) as the base font. By default DTCoreText seems to create the NSAttributedString with the Times New Roman font. I'd really...

iOS, Keyboard Predictive bar visibility

ios,uikit,uitextview,uikeyboard
I have some instance of UITextView and I want this textView to occupy all empty vertical space when keyboard is shown. The problem is that I do not know what height will keyboard take as it has predictive bar in iOS 8 and its actual height can be changed by...

reloadRowsAtIndexPaths side effects?

ios,uitableview,cocoa-touch,uikit
I have an UITableView filled with UITableViewCell that contain a checkmark. When I click on a cell, if it was marked it becomes unmarked and vice-versa. So far so good. Now I want to update the first cell every time I click on any other cell (assume the first cell...

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

ios,objective-c,cocoa,uikit
Is there a way to check if a property has been set on an UIAppearance proxy or not? Let's say I want to do something like: self.lineWidth = appearance.lineWidth ? : kDefaultLineWidth; This will not work correctly if the lineWidth was set to zero on the proxy since it would...

UITableViewCell auto-sizing height not working

ios,objective-c,uitableview,uikit
The cells in my table view are not auto-sizing their height to contain the content. I am using the "Basic" style for the cell prototype. I created a new test project containing only my view controller and a storyboard and it has the same issue. What am I doing wrong?...

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

ios,uiviewcontroller,uikit,rubymotion
I have a UIViewController with a container view and I'm using auto layout. I have programmatically added another view controller as a child and added its view as a subview and set the view frame to the same as the container view. Everything is fine and when I animate a...

textField shouldChangeCharactersInRange is executing one step behind user action

ios,swift,uikit
I have a textField into which the user types an email address. I want to activate the submit button at the instant the input text becomes a valid email address. The validation works, but the code in shouldChangeCharactersInRange appears to execute one step behind the user input. So when the...

Multicolored UISlider, is it possible?

ios,uikit,uislider
I often see UISlider's with a little yellow line through them, generally indicating an advertisement or something similar. I'm trying to replicate this functionality, and am wondering about the best way to approach this. Can you change specific x-cordinates on the UISlider to be a different color? I'd rather not...

Implementing UIWebView inside UIScrollView

ios,iphone,uiwebview,uiscrollview,uikit
I'm trying to use UIWebView inside UIScrollView, I want to display an webview under an image and make them scrollable. So I flowed those step : Desactivate the Scroll Property for UIWebView Set the UIScrollView and UIWebView height equals to content size. And this my code : - (void)viewDidLoad {...

iOS Swift: Crash on deleteRowsAtIndexPaths

ios,swift,uikit,icloud,cloudkit
I'm getting a crash when I remove a row from a tableView. Not sure what's going on. Here is my code: func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) { let items = days[indexPath.row] self.removeItems(items, indexPath: indexPath) } func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return days.count...

How to share multiple urls via UIActivityViewController?

ios,objective-c,cocoa-touch,uikit,uiactivityviewcontroller
This is my code: NSArray* itemsToShare = [self itemsToShare:items]; // array of NSURLs if (itemsToShare.count) { UIActivityViewController* activityVC = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare applicationActivities:nil]; UIViewController* controller = self.platformManager.sharePanel.navigationController.topViewController; [controller presentViewController:activityVC animated:YES completion:nil]; } If itemsToShare.count is greater than 1 UIActivityViewController doesn't show Facebook and Twitter icons. If the array...

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

ios,objective-c,swift,uikit
When using Objective-C and importing headers, it made sense to me what was getting imported. For example, I only have to import UIKit but I can use CoreGraphics, for example. How can I tell what other frameworks each framework is importing with Swift? All I'm doing is importing UIKit, but...

Reuse a function across multiple UIViewControllers

ios,swift,uikit
I'm able to reuse a variable across multiple UIViewControllers, by storing it in a separate Swift file in my project, but I can't seem to do the same with a function. It simply doesn't get recognized the way variables do. How can I do this?...

Cannot display UIUserNotificationActions in foreground (default context)

ios,objective-c,uikit
I am trying to get a set of user notification actions to display with more than 2 buttons. The notification itself utilises the minimal context when app is in the background and this works fine. When the notification is called while in the foreground, the application:didReceiveLocalNotification: is called as per...

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

ios,swift,uiviewcontroller,uikit,xcode-storyboard
What I am trying to do simply change views based on some data. To demonstrate exactly what I am trying to do I have constructed a little example to demonstrate. I used a UISegmentedControl to simulate data data then when a button is pressed, it would switch between views based...

WatchKit UIPageControl Dot Colour

ios,uikit,apple,uipagecontrol,watchkit
When I was watching one of the videos from Apple about the Apple Watch and its features I noticed that the page indicator dot colours change depending on the page presented. They've also got images of the coloured dots within the Apple Watch Human Interface Guidelines App Anatomy section. Note...

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

ios,objective-c,uikit
Now first of all, I am not asking how to add a gesture recognizer or how to create a button. What I want is to know that "somebody touched the screen in any way", without interfering with the related screen element. The thing is that I have elements that the...

Delaying IBAction Button

ios,objective-c,cocoa-touch,uibutton,uikit
I want to delay this button for 23 hours, which is 82800 seconds. It should work fine, the button does delay after one click, however when I switch to another view controller, or re-enter the application, the button delay function fails to work as it just pops back to clickable...

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

ios,uitableview,swift,uikit
I have a loop like so that creates a string representing a url: for(var i = 1; i < 6; i++) { let urlString: String = "http://{...}/data/\(i).txt" var downloader = FileDownloader(url: urlString, array: peopleArray, table: theTable) downloaderQueue.addOperation(downloader) } FileDownloader constructor is as follows: let urlString: String var personArray: Array<Person> =...

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

ios,uikit,autolayout,uisplitviewcontroller,size-classes
I have a UISplitViewController that is used to edit some text. The flow is basically like this: The user creates a new note. The user is transitioned to the Detail View Controller to create or edit said note. User can edit the text in either portrait or landscape. The problem...

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

ios,storyboard,uikit,paint-code
I followed the PaintCode tutorials on StyleKit and I've successfully exported icons into a Swift project (code only - MyStyleKit.swift file). I'm trying to understand the relationship between the UIImage generated in code and the image sizes expected for different iOS devices. I wired up the MyStyleKit object in the...