FAQ Database Discussion Community


UITextField and tap gesture in leftView

ios,objective-c,cocoa-touch
I've an icon on leftView of textField and I want to add tap gesture to it. This is my code : if (!textField.leftView){ UIImageView *infoImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 18)]; infoImage.image = [UIImage imageNamed:@"info"]; infoImage.contentMode = UIViewContentModeCenter; textField.leftView = infoImage; textField.leftViewMode = UITextFieldViewModeAlways; UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc]...

NSMutableArray Thread Concurrency with GCD

ios,objective-c,multithreading,cocoa-touch
I have an NSMutableArray in a "sharedStore"-pattern singleton. Publicly, it's accessible only through methods that cast it as an NSArray. Within the class, it's @property (nonatomic, copy) NSMutableArray *myItems; This array never gets manipulated outsdie the singleton but ViewControllers send the singleton messages to manipulate this controller. Some of these...

Stop Infinite Constraint Animation

ios,cocoa-touch,autolayout
I have been struggling to stop/remove an infinite constraint animation after it starts. Basically I have a box that has a constraint of equal height to the main view with multiplier 0.5. The box is supposed to grow and shrink by changing the multiplier to 0.8 and back to 0.5...

passing the imageView to the next activity, does it require an outlet

ios,swift,cocoa-touch
I have minor problem that whenever I delete the Outlet (imageChosen) shown in the picture below (with the yellow warning), the app crashes when the image supposed to be passed here how i defined it var imageChosen: UIImageView! this is how i saved the image chosen from the gallery to...

Compare dates from given array and two date ranges swift

swift,cocoa-touch,xcode6,compare,nsdate
Hi i have a problem scenario with date comparison with given date range the scenario is as follows: i have an array containing data: var filter1Date = [String]() filter1Date[Wed, 06 May 2015 03:44:19 GMT, Wed, 06 May 2015 03:36:27 GMT, Wed, 06 May 2015 02:56:51 GMT, Wed, 06 May 2015...

How do I change the initial tab bar selection in swift?

ios,swift,cocoa-touch
In trying to find a solution I came across this answer: [ http://stackoverflow.com/a/10441200/4856759 ] It seems to accomplish what I want it to, but in objective C: UITabBarController *tabBar = (UITabBarController *)self.window.rootViewController; tabBar.selectedIndex = 0; How do I do this in swift? My first attempt returns an error: cannot convert...

Making an asteroid explosion with asteroid bits [closed]

cocoa-touch,sprite-kit,particle
How do I make the asteroid explode with small bits exploding outward? I'd need a texture animation for the asteroid cracking, but I'm not sure how to use the particle emitter to have random sized asteroid bits fly out. And would these bits collide and bounce off other objects? http://www.startalkradio.net/wp-content/uploads/2013/05/asteroid-and-white-dwarf.jpg...

How to talk to superview's controller?

ios,objective-c,cocoa-touch
I have UIView subclass that is being added to my View Controller's main view. It contains audio player controls and slides in when an audio item is being played. I am already updating the view’s UI to reflect the playing state (elapsed duration, etc.) just fine. What I'm wondering is...

NSCalendar.components().minute returning inconsistent values

ios,objective-c,swift,cocoa-touch
Original problem is encountered during my post, testing and code in the link below http://stackoverflow.com/questions/27339072/working-with-nsdate-components-in-swift/30822018#30822018 Here is the minimal test-case I am creating a date that is offset from a particular date (self in this case as I do it in NSDate() extension) using NSCalendar.dateByAddingUnit(..., value:x, ...) I then get...

Using Custom UIAlertView xCode - Including Dialog/Text?

c++,cocoa-touch,uialertview
So I've been searching for a good way to include images and additional stuff into UIAlertViews in iOS 8. I eventually found this answer, which uses this custom class from Github which someone kindly uploaded. It works great and looks amazing, but I'm not sure how you actually include dialog...

How do I create a Textfield for Tag-Like-Text Input in iOS?

ios,cocoa-touch,uitextfield
I'm creating a app where the User can input text (words or short phrases) by pressing several buttons. The text gets inserted into a UITextField, where the user can input additional text of his own. To simplify interaction with the already inserted text, I'd love to have a behavior that...

UITableViewAutomaticDimension + AFNetworking

ios,iphone,uitableview,cocoa-touch,afnetworking
I'm loading images from an API, and they have different heights and displaying in a UITableView which contains other type of cells (the reason I'm using UITableViewAutomaticDimension) I wanted to display (or reload) the cells containing the images using the image height, to avoid distortion. I tried different solutions, but...

How to change data in the userInfo when using NSTimer?

ios,iphone,cocoa-touch,nstimer,userinfo
I use NSTimer to repeat a function every 1 second. I use scheduledTimerWithTimeInterval method's userInfo parameter. I need to update data in this userInfo. override func viewDidLoad() { super.viewDidLoad() NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: "minus:", userInfo: ["number": 100], repeats: true) } func minus(timer: NSTimer) { var userInfo = timer.userInfo as! Dictionary...

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...

Change NSTimer interval after a certain number of fires

objective-c,cocoa-touch,nstimer,intervals
In the following code, the NSTimer interval is set at 1 second between each picture. My goal is to change the interval after the first two pictures, hello.png and bye.png, to 4 seconds. - (void)viewDidLoad { [super viewDidLoad]; NSArray *imageNames = @[@"hello.png",@"bye.png",@"helloagain.png",@"bye again"]; self.images = [[NSMutableArray alloc] init]; for (int...

Binary operator '|' cannot be applied to two UIViewAutoresizing operands

ios,swift,cocoa-touch,swift2
Getting this error in Swift 2.0. Binary operator '|' cannot be applied to two UIViewAutoresizing operands Here is the code: let view = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 568)) addSubview(view) view.autoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight Any idea what can be the problem? ...

Decrypt p7s file on iOS

ios,objective-c,cocoa-touch,nsdata,pkcs7
Working on a test iOS app I have faced the following problem. From a remote webserver I recieve a .p7s file with the following contents (which are viewable in Mac's TextEdit app): 0Ä *ÜHܘ †Ä0Ä10 +�0Ä *ÜHܘ †Ä$ÄÇ˚<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict>...

Set CALayer Gradient Background

objective-c,xcode,osx,cocoa,cocoa-touch
I am trying to add a gradient to a CALayer I have created. I can set the background colour of the CALayer with the following: self.colorLayer = [CALayer layer]; [self.colorLayer setBackgroundColor:color.CGColor]; [self.colorView setWantsLayer:YES]; [self.colorView setLayer:self.colorLayer]; I've looked around with no success (surprisingly I thought this would have been answered many...

UITabBarItem image colour changes to blue after first time it is selected

ios,swift,cocoa-touch,uitabbarcontroller,uitabbar
I'm having this issue with a UITabBar. I have custom images I'm using for the UITabBarItems and after I select a tab the correct highlight colour shows but the original colour of the image (grey) is no longer grey. it is no blue. So basically: I select a tab and...

How to change the font size of a single index for UISegmentedControl?

ios,objective-c,cocoa-touch,uisegmentedcontrol
The way to change the font size for a UISegmentedControl would be the following: UIFont *font = [UIFont systemFontOfSize:13.0f]; NSDictionary *attributes = [NSDictionary dictionaryWithObject:font forKey:UITextAttributeFont]; [self.segment setTitleTextAttributes:attributes forState:UIControlStateNormal]; How can I change the font size for a single index in a UISegmentedControl? Or even better, if the text doesn't fit...

iOS not requesting location services when request code executes

ios,objective-c,cocoa-touch,core-location
I have a weird bug happening in an iOS app I am developing (Objective C). I am using location services inside an object that is created and stored as an instance variable of the root view controller class. This object is initialized in the viewDidLoad method. if (sunEventObject == nil)...

Changing button label in the container view by clicking button in the main view

ios,swift,cocoa-touch,containers,segue
I'm new to IOS programming. In my app, I have a container view which is connected to a page view controller with three pages. It works well. When I push a button in the main view controller, I want to change the button labels in the container view. So, I...

iOS - Adding Subviews to Child View Controller view

ios,objective-c,cocoa-touch,frame,viewcontroller
I am trying to add subviews to the view of a child view controller. The child view controller is created when a button is pressed. The parent view controller is inside a navigation controller. -(void)weightPlatePressed:(id)sender { NSInteger week = self.weekControl.selectedSegmentIndex + 1; NSInteger set = self.setControl.selectedSegmentIndex + 1; NSInteger max...

Cocoa Touch Framework fails to debug on simulator in embedding project

ios,objective-c,xcode,cocoa-touch
I've got a Cocoa Touch framework built with XCode 6 targetted towards iOS >= iOS8. This framework's target architecture settings are default, meaning that I haven't changed anything. The architectures are set to standard (which doesn't include x86_64, more on that later). The framework itself contains both Swift and Objective-C...

How to extend the Swift Dictionary type to return a non-empty String or nil

ios,swift,cocoa,cocoa-touch,foundation
I'm writing an extension to Dictionary so that when I give it a String key, it'll return me a String only if the value associated with the key is non-nil and not empty. extension Dictionary { subscript(key: String) -> String? { if let string = super.subscript(key) { if string.isEmpty ==...

Strange constraint behaviour in UIPageViewController

ios,objective-c,cocoa-touch,uipageviewcontroller,nslayoutconstraint
In storyboard I have UINavigationController without navigation bar and with root view controller UIPageViewController that has 2 children: LoginVC and ChoosePlaceVC. MainPageVC is a simple subclass of UIPageViewController where I just set [self setViewControllers:@[loginVC] direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil]; In Login ViewController I set constraint to top for logo image to 0...

Autolayout: table cell with variable height and two labels

ios,cocoa-touch,autolayout
I am stuck with a bit of an advanced Autolayout topic where I need some help of you. I have a simple custom table cell with a label pinned on the left side, and one pinned on the right side, pretty simple: Now, I want the left label always to...

How do I programatically create labels with separators in an Apple Watch UI [closed]

ios,cocoa-touch,watchkit,ios-extensions
I would like to create a for loop for adding labels with separators programatically. How can I do this? ...

Getting NULL value back in UITableView from SQLite database

ios,objective-c,cocoa-touch,sqlite3
Program is running without issue I can see the database being opened When I add an item to the app, it shows up as NULL in the UITableView I have unit tests that test each action: create, update, delete, and count. These all pass Here are my unit tests: -...

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...

Third Estimote beacon triggered by startMonitoringForRegion does not receive didEnterRegion or didExitRegion

ios,cocoa-touch,bluetooth-lowenergy,cllocation,estimote
In my app delegate I am registering to receive updates for didEnterRegion and didExitRegion. Specifically, in didFinishLaunchingWithOptions I declare and register to the beacons like so: //Setup the beacon monitoring CLLocationManager *locationManager = [[CLLocationManager alloc] init]; locationManager.delegate=self; for(CLRegion *r in locationManager.monitoredRegions){ [locationManager stopMonitoringForRegion:r]; } self.beaconManager = [[ESTBeaconManager alloc] init]; self.beaconManager.delegate...

NSTimer, setNeedsDisplay, unrecognized selector issues

ios,swift,cocoa-touch,nstimer
The logic for this app is functioning, but the timer is not functioning properly. I have three files: ViewController.Swift, clock.swift, and clockstylekit.swift. updateTime(), located in the clock.swift file pulls the time, breaks it into its components, and returns hours, minutes and seconds and summons drawRect to redraw the visual representation...

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...

Cocoa Touch Framework: Constants

objective-c,swift,cocoa,cocoa-touch
i want to write a Cocoa Touch Framework in Swift and want to use it in different projects. As far as everything works fine. Now I would like to extend my framework with constants which I can use outside of the framework. My problem is that i can't use the...

iOS - Can saving to Library/Caches/ result in error?

ios,iphone,cocoa-touch
If an app starts saving virtually unlimited images (on demand) to the /Library/Caches directory for caching purpose, what will happen when the storage is full? Will saving to the caches folder result in error? OR If the app is open, can the cache of the open app be purged by...

Strip down webpage to just text on iOS (Objective C)

html,ios,objective-c,cocoa-touch
My main goal here is to achieve an effect like Readability or Safari's Reader service where the main content of the webpage is converted to text. I don't actually want to display any images, just get all the webpage's important text. I am currently using some pretty long self-built code...

Cannot invoke scheduledTimer

ios,swift,cocoa-touch
I have this very simple code to trigger a timer: var timer = NSTimer.scheduledTimerWithTimeInterval(NSTimeInterval(2), target: self, selector: "timerDidFire:", userInfo: nil, repeats: true) However it's giving me: Cannot invoke 'scheduledTimerWithTimeInterval' with an argument list of type '(Double, target: TestVC -> () -> TestVC, selector: String, userInfo: nil, repeats: Bool)' Which doesn't...

Redirect a View with Push Notification in AppDelegate

ios,swift,cocoa-touch,push-notification,uistoryboardsegue
My aim is writing a code that when a user gets a push notification, I want that user to be redirected to another view. If the user comes with the push notification and if he has been first viewed the controller (welcome home screen etc. (but not logged in)) var...

Does the iOS Documents Directory need to be constructed every time?

ios,objective-c,cocoa-touch
I'm writing an iOS App that does a considerable amount of file operations. It's tedious to do [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] every time to get the Documents directory's root. Is it necessary? Can I somehow store it in some kind of global variable?...

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...

How to create UITableViewCells with complex content in order to keep scrolling fluent

ios,swift,uitableview,cocoa-touch,ios-charts
I am working on a project where I have a table view which contains a number of cells with pretty complex content. It will be between usually not more than two, but in exceptions up to - lets say - 30 of them. Each of these complex cells contain a...

Display cell in a TableViewController chronologically - Swift

ios,swift,cocoa-touch
I want to display cell chronologically in a TableViewController. I use a Item.swift and a ItemStore.swift to save data but when I display with data in cell I have: 1(first item save)- 2(second item save)- 3(...) But I want: 3- 2- 1

programmatically scroll to a specific page/position with autolayout iOS

ios,cocoa-touch,uiscrollview,autolayout
I am using autolayout with a scroll view. It is working great, but I need to be able to scroll to specific pages programmatically. Specifically, I need to scroll to the last page after the view loads. How do I do this? My scrolling essentially has the visual format shown...

How to Nil a object in Swift

ios,swift,cocoa-touch,null
How to assign nil to an object in Swift. I'm getting error if assigned directly. ...

Rounded Ends on Circular Graph? iOS?

ios,cocoa-touch,graph,charts
I am trying to reproduce the rounded ends on the circular graph it is not working out for myself. I tried google and cannot find the exact terminology to recreate it. Can anyone lead me in the right direction or tell me what I am looking for ? I want...

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....

Mixing storyboard and constraints in code

ios,iphone,swift,cocoa-touch,autolayout
I'm trying to implement view controller from this wireframe As we have different screen resolutions - different number of yellow views can fit on the screen. All yellow views are same size UIImageViews, containing the same image. What I'm trying to do is to layout view controller in storyboard except...

Most efficient way to create an NSMutableArray from NSArray

objective-c,cocoa,cocoa-touch,nsmutablearray,nsarray
Which of these, if either, is more efficient? NSMutableArray *array = [NSMutableArray arrayWithArray:@[@1, @2]]; or NSMutableArray *array = [@[@1, @2] mutableCopy]; Or are these the same internally?...

Add a angle to CAGradientLayer OSX cocoaTouch

ios,objective-c,xcode,osx,cocoa-touch
How can I add a angle (rotate) my CAGradientLayer? Without rotating my view (self.colorView). I just want to add a angle to the gradient I create my CAGradientLayer like below CAGradientLayer *gradient = [CAGradientLayer layer]; gradient.colors = [NSArray arrayWithObjects:(id)[[NSColor blueColor] CGColor], (id)[self.gradColorTwo CGColor], nil]; gradient.frame = self.colorView.bounds; [self.colorView setLayer:gradient]; [self.colorView...

Changing the position of a CorePlot annotation after zooming(iOS)

ios,objective-c,cocoa-touch,annotations,core-plot
I am using a CorePlot ScatterPlot to display data readings from an external bluetooth sensor. Ive gone through the following tutorial: http://www.raywenderlich.com/13271/how-to-draw-graphs-with-core-plot-part-2 and Ive got everything working the way that I would like with one exception. When the user taps on one of the data points, an annotation is placed...

Best practice when adding constraints programatically in Swift

swift,cocoa-touch
I am adding some constraints to an UIView programmatically in Swift. My question is when in the ViewController life cycle is it best to add the constraints? Should I add it in viewDidLoad or viewWillAppear, maybe even viewWillLayoutSubviews. Does anyone know if it even matters where I add the constraints?...

iOS Keyboard “Done” button load action

ios,swift,cocoa-touch
I'm trying to get "Done" button on to load an action, preferably the action that I have for my button. Here's the UITextField declaration let someTextField = UITextField() Trying to add a target to the textField someTextField.addTarget(self, action: "loginActionButton", forControlEvents: .EditingDidEndOnExit) ...

Concurrent processing on main queue during UITableView scroll

cocoa-touch,grand-central-dispatch
I have a stopwatch screen in my app. There is a main label indicating passing time every 100 milliseconds (updates constantly). Just below that label, in the same ViewController I have a UITableView. Whenever I'm scrolling the UITableView, the stopwatch labels stops updating. I've tried using Grand Central Dispatch as...

iOS should model objects be able to access network with NSURLSession

ios,objective-c,cocoa-touch
I am in the middle of an app re-design and am refactoring and extending my model. One aspect of my apps model is that the app retrieves data from a web service and populates the model. My question is: Should my model objects have the capability to implement NSURLSession or...

Obj-C, changing autolayout at runtime, woes

ios,objective-c,cocoa-touch,autolayout,ios7.1
I'm trying try hide table view and move a button up the screen, which is different to my autolayout setup. Basically, I have a free version of my app where I hide things, then if they purchase I need to set the constraints back to those in interface builder. I...

Two different colors in one word in an NSAttributedString

ios,swift,cocoa-touch,nsattributedstring,text-styling
Can I somehow add multiple colors to a single word in an NSAttributedString? In other words, I want to add colors to specific words, with or without a space between colors, such as <red>app</red><blue>ple</blue>. That way apple has two colors. I have attached photos of what happens before and after...

Mail Compose View Controller won't dismiss when called from NSObject

objective-c,cocoa-touch
I have several View Controllers that need to send emails, so to keep things Object-Oriented, I created an NSObject class called MessagingObject to handle these messages. But I'm not sure how to dismiss the MailComposeVC since it's coming from a non-VC object. The implementation looks like this: //.m file #import...

Core Data inputting numbers > 1.0 error

ios,cocoa,cocoa-touch,core-data,nsnumber
I'm working on coding a journal application which uses core data to store amongst other things, theme data (what the app looks like) - this was working until recently when I changed quite a lot of code. I'm now coming across an issue when trying to import a float into...

UIAlertController translucency glitch/bug

ios,cocoa-touch,uialertcontroller
When iOS presents an alert, the translucency is constant. When my app presents one, the alert is white at first, only for half a second, then it becomes translucent. It's a small issue, but it looks messy and alerts should be consistent everywhere I think. Anyways here is the code:...

UIPickerView is Selecting the Wrong Row-Swift

ios,swift,cocoa-touch,uipickerview
So I have UIPickerView that isn't working the way I want it to. It works correctly about 3/4 of the time, but the other 1/4 it doesn't. func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int { return 1 } func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { return listsArray.count } func pickerView(pickerView:...

Return to app from background on iOS

ios,cocoa-touch,iphone-privateapi
I have an app that works in background successfully. It also has a working URL scheme set up and running. Now I need to implement the following scenario - after 5 seconds in background I want the app to open itself up - and make it a foreground one. The...

Detect WatchKit extension presence in app

ios,cocoa-touch,watchkit
I have an app that I want to behave a bit differently when it comes to updates and caching if a WatchKit extension is installed on your paired Apple Watch than if it is not. If the watchkit extension has any chance of launching (you have paired a watch and...

How can I add a panGestureRocgnizer To a TableView, and still have the tableview scroll while recognizing pans right?

ios,objective-c,uitableview,cocoa-touch
I'm using an ECSlidingViewController (github hamburger-menu/slide-out menu project). I have a TableViewController, and I need to add the following to my TableViewController. ECSlidingViewController *ecsVC = (ECSlidingViewController *)viewController; ecsVC.panGesture.delegate = self; [self.view addGestureRecognizer:ecsVC.panGesture]; I cannot do self.navigationcontroller.view addGestu..., because if I push a view, then I still get the pangesture functionality...

How do I call a static function of a class by its instance

ios,swift,cocoa-touch
I have a simple class: class TableItem { class func cellIden() -> String { return "TableItem" } } and a subclass of TableItem class EditableItem { override class func cellIden() -> String { return "EditableItem" } } Then, somewhere in my code, I have this: var items: [TableItem] = [TableItem(),...

Parsing a date string gives [__NSDate length] unrecognized selector exception [duplicate]

objective-c,cocoa,cocoa-touch,nsdate,nsdateformatter
This question already has an answer here: Converting NSDate to NSString causes unrecognized selector exception 2 answers I have an NSDictionary that holds a date like this: "2015-05-23 21:04:11 +0000" and I'm trying to parse it like: NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setDateFormat:@"yyyy-MM-dd HH:mm:ss z"]; NSDate *date...

Auto check textfield length and Hit a method UITextfield

ios,objective-c,cocoa-touch,uitextfield
Hello I need to enter mobile number with validation that mobile textfield range should be 10. And when textfield value ==10, i need to call a function when mobile textfield.text length becomes 10. My below code work fine but i need to press 1 more character (means 11) to call...

UITextField NSForegroundColor turns transparent after screen rotation Swift

ios,swift,cocoa-touch
I am having a problem that the UITextField font foreground color turns transparent after screen rotation. Below is my code. let TextAttributes = [ NSStrokeColorAttributeName : UIColor.blackColor(), NSForegroundColorAttributeName : UIColor.whiteColor(), NSFontAttributeName : UIFont(name: "HelveticaNeue-CondensedBlack", size: 40)!, NSStrokeWidthAttributeName : 3.0 ] //In viewDidLoad textFieldTop.delegate = textFieldTopDelegate textFieldTop.text = "TOP" textFieldTop.frame =...

Why are my custom annotation images changing?

ios,objective-c,cocoa-touch,mapkit,mkannotationview
I have 21 different images that I am using for custom annotations on a map. When I load the map initially, everything is perfect. It is when I navigate off of the area and back in that it seems that the images change. The annotation pins no longer correspond with...

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 {...

Method that returns block

ios,objective-c,cocoa-touch,objective-c-blocks
I wrote a method that can be used with a dot notation, using block tricks - (RaginiDBQuery *(^)(id object))where; This method can be called using a dot notation since basically it doesn't receive any parameters, (it does, but by using the block returned) So I can call it like so:...

SKShapeNode not drawing UIBezierPath

ios,swift,cocoa-touch,sprite-kit,skshapenode
Calling this code inside the didMoveToView() of my SKScene: let frame = CGRect(x: 30, y: 200, width: 100, height: 100) let path = UIBezierPath(rect: frame) UIColor.blackColor().setStroke() path.stroke() self.addChild(SKShapeNode(path: path.CGPath)) does absolutely nothing. The scene is empty (it has the default SKScene grey background). Here I'm just trying to draw a...

Adding a fixed-position view on top of a view

ios,objective-c,cocoa-touch
I have a UITableViewController inside a UINavigationController. I'm adding a "modal" subview to the tableView, which is a custom UIView when one of the rows is selected. (It’s modal in spirit, not in the UIKit sense, since Apple doesn’t support modal views on iPhone, I’m adding it with a [self.view...

Delete NSManagedObject from a tableView and correctly re-load view

ios,uitableview,cocoa-touch,core-data,nsmanagedobject
I am trying to suppress a NSManagedObject from a table view. I have a TableView controller that subclasses UITableViewController and that owns an additional property of type myContainer as well as an array of items. @property (nonatomic, strong) myContainer * parentContainer; @property(nonatomic, strong) NSArray * allItems; myContainer is a NSManaged...

Getting wrong keyboard frame with auto-completion

ios,swift,cocoa-touch
I trying to adjust my layout using the UIKeyboardDidChangeFrameNotification to get notified when the keyboard changes frame. My function that adjust the layout is getting called properly and works well unless the auto-completion feature is off. func keyboardFrameChanged(notification : NSNotification) { println("Keyboard frame changed") var rect = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey]?.CGRectValue())! println(rect) }...

Swift - Is linking to required framework always necessary?

ios,xcode,swift,cocoa-touch
A lot of tutorials on frameworks (AVFoundation, AudioToolBox, Social, MPMediaPlayer, iAd, etc) start by saying that it is must to link the respective frameworks (target settings ->build phases->link binary with libraries->add frameworks). Most of the times I have found the import statement alone to be sufficient and my app works...

In custom iOS keyboard detect the app

ios,objective-c,cocoa-touch,keyboard,ios-extensions
How to detect in which app my custom keyboard used and show different button? E.g. in Twitter I would add @ to string I post into input field and in Reddit /r/

UIAlertAction completion block not called - iOS

ios,objective-c,cocoa-touch,uiactionsheet,uialertcontroller
I have an iOS app with a UIAlertController in the form of a action sheet being presented in my app when the user taps on a button. It all works great, apart from one thing, the completion blocks don't get called for some reason. Here is my code: // Setup...

Is there a way to have custom UIBarButtonItems in a Toolbar that go against the HIG?

ios,cocoa-touch,uibarbuttonitem,uitoolbar
These are the Human Interface Guidelines for UIToolBar Icons, and Bar Button Icons. I want something that doesn't exactly follow the HIG. Basically I want a solid rounded and flat colored UIButton, with text overtop. (However, I don't want text to be apart of the image for obvious reasons). Can...

How to change the text 'More' on the standard UITabBarItem

ios,objective-c,cocoa-touch,uitabbarcontroller,uitabbaritem
I have a TabBarController with several UITabBarItems, the last of those items is the standard 'More' UITabBarItem provided by iOS. I want the title to be 'Meer' (More in my language), but when I try to set the title programmatically it doesn't work. I've tried this: UITabBar *tabBar = self.tabBar;...

Indicator within alert, indicator doesn't show up (resolved using UIAlertController)

ios,objective-c,cocoa-touch,uialertview,uiactivityindicatorview
I'm trying to follow the accepted solution from here on Xcode 6.3.2 but the indicator refuses to show up or I can't see it on my iPhone 6 plus for some reason. No error messages, the alert with the title, etc shows up and empty space. What am I doing...

Convert long month name to int

swift,cocoa-touch,nsdate,nsdateformatter,date-parsing
I understand how to use an NSDateFormatter to convert a month component into a long name string, but how does one convert a month name to an int? I've been using a switch statement to convert, but I'm thinking there must be a simpler way. For example, I'd like to...

Swift ViewController textFieldCancel:]: unrecognized selector sent to instance during segue [duplicate]

swift,cocoa-touch,ios8,segue
This question already has an answer here: “Unrecognized selector sent to instance” error 3 answers I've run into an annoying issue when trying to segue to a Pages View Controller from my initial UIViewController. My initial UIViewController, among other things, includes a UITextField. Everytime I attempt to segue out...

recognize the different view tag via UITapGestureRecognizer

ios,objective-c,cocoa-touch
I use the code below to add touch TapGestureRecognizer on 3 views. UITapGestureRecognizer *anUITapGestureRecognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(doSomeThing:)]; view1.tag=1; [view1 addGestureRecognizer:anUITapGestureRecognizer]; view2.tag=2; [view2 addGestureRecognizer:anUITapGestureRecognizer]; //... view3.tag=3; [view3 addGestureRecognizer:anUITapGestureRecognizer]; same as but if I tap view1, view2, view3, the code below will output 1, 2, 3 - (void)doSomething:(UITapGestureRecognizer *)tap { NSString...

Check whether NSDate is Monday/Tues/etc

ios,objective-c,cocoa-touch,date,nsdate
I have an iOS app which needs to set a few different date labels according to the current day. I am using NSDate and NSDateFormatter to do this. However there is something I am not sure about: if the user has an iOS device with their language/localisation set to something...

Using UIProgressBar to show percentage?

cocoa-touch,uiprogressview
I was hoping there was a way to utilise the UIProgressBar by having it show the percentage or something instead of it animating/loading. For example, if in a game you have collected 25/100 coins, the progress bar would be lit 25% of the way... I haven't been able to find...

iOS Data didn't sent to custom TableViewCell

ios,objective-c,cocoa-touch
I'm working on a project that using a custom TableCell. Here's my code - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"customScoreCell"; ScoreTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (!cell) cell = [[ScoreTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; cell.classNameLabel.text = courseNameArray[indexPath.row]; cell.creditLabel.text =...

How can I modally present a UIViewController on another Storyboard that's embedded in a UINavigationController?

ios,objective-c,cocoa-touch,uiviewcontroller
...and have it embedded in a navigation controller. I have a storyboard, let's call it MainStoryboard. On main storyboard (neither is the initialViewController BTW), I have a ViewController, let's call it ViewControllerZ, embedded in a NavigationController, let's call it NavigationControllerZ. Upon a user clicking a button... I had... UIStoryboard *storyboard...

IOS Swift handle global events

ios,swift,cocoa-touch,events
How can I handle global events triggered by the notification centre for example in my API class I fire an event if an error response is received e.g. (500). When that event is fired an UIAlert should be displayed on what ever view controller is active, or on logout the...

Imports and includes in header files - when is it okay?

objective-c,cocoa,cocoa-touch
I've read that the rule is to not #import or #include anything in .h files. Is that really true, though? Just today I've run into two separate occasions where I had to do it, one where I import a header file that contains a typedef enum because my method stubs...

Pass data between 2 view controllers that are not directly linked

ios,objective-c,cocoa-touch
I have a Main Menu-type View Controller (let's call it MainVC) with 2 buttons - one modally presents another regular VC (SourceVC); the other pushes a Table VC (DestinationVC). SourceVC and DestinationVC are NOT directly connected. Whenever the SourceVC performs MethodX, it creates an object. I want SourceVC to send...

Get current URL in UIWebview but it not respond

ios,objective-c,cocoa-touch,uiwebview
I create app to use UIWebview and show log to url if touch in content in UIWebview. this is my code - (void)viewDidLoad { [super viewDidLoad]; NSURL *url1 =[NSURL URLWithString:@"MyWebSite"]; NSURLRequest *request1 = [NSURLRequest requestWithURL:url1]; [_webView1 loadRequest:request1]; NSURL *url2 =[NSURL URLWithString:@"MyWebsite2"]; NSURLRequest *request2 = [NSURLRequest requestWithURL:url2]; [_webView2 loadRequest:request2];//url menu 2...

Repeating local notification daily at a set time with swift

ios,swift,cocoa-touch,uilocalnotification
I am new to iOS development, but have created the app and I am trying to create a daily notification for a set time. Currently the notification executes once for the given date/time. I am unsure how to use the repeatInterval method to schedule it daily. What is the best...

Get name of img from for loop

objective-c,cocoa-touch,uiimage
I have the following code to display the images: _image = [[imagesModel alloc] initFromURLWithString:imageURL completion:^(id model, JSONModelError *err) { int x = 0; int w = 1; for (imageModel *img in _image.Images) { NSString *picString = [NSString stringWithFormat:picURL, img.filename]; NSLog(@"Images: %@", picString); UIImage *getImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:picString]]]; UIImageView...

Change a constraints constant using code

ios,swift,cocoa-touch,constraints
I am creating this generic base code for all my views, It creates an ad bar that flows across all my pages. I have just included some code from the best answer to this Question and I cant work out why it doesn't work. I am trying to make it...

UITextInput: reset multi stage input suggestions

ios,cocoa-touch,uitextinput
In my app I have implemented UITextInput to handle multi stage text input for my custom UITextField. I was wondering if anyone knows how to reset the multi stage input suggestions that appear above the keyboard when typing on the Japanese keyboard: I'm just wanting to clear out the marked...

Why does an orientation change AutoLayout for my UITableViewCell?

ios,uitableview,cocoa-touch,autolayout,orientation-changes
I am trying to use AutoLayout inside a UITableViewCell with Objective-C. I am not using a nib/xib/storyboard. I create my views in code. Here's my UITableViewCell: @implementation SettlementTableViewCell - (instancetype) initWithReuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier]; if (!self) return nil; [self setSelectionStyle:UITableViewCellSelectionStyleNone]; _order = [[UILabel alloc] init]; [_order...

How can I animate a UITabBar off the screen and recognize taps where it would normally reside?

ios,objective-c,cocoa-touch,uitabbar
No using "hidesBottomBarWhenPushed". I've tried animating the UITabBar down so that the Y is the same as the self.view.bounds.frame.y. In my viewController I also have a tableView that has a Bottom constraint from the TableView to the SuperView. Call it self.constraintTableViewBottomToSuperViewBottom. I'm setting subtracting to this constraint the height of...

How to approve uploads to CloudKit

ios,cocoa-touch,icloud,cloudkit
When creating an application that uses CloudKit, sometimes you allow the user to create and upload data to the public database which will be publicly available to everyone once it's created. This leads to my question which is: How do you review/moderate/approve user created data before making it available to...

Return value for method from closure in Swift

ios,swift,cocoa-touch
Is there a way that I can return value for shouldPerformSegueWithIdentifier method from my closure? Or should I do it differently? override func shouldPerformSegueWithIdentifier(identifier: String?, sender: AnyObject?) -> Bool { getDataFromSomewhere() { succeeded, data in if succeeded { // Should return true here } else { self.errorAlert("Error", message: "Can't get...

How do I figure out when the contents of NSData indicate that a webservice request has failed?

ios,objective-c,web-services,cocoa-touch,nsobject
I'm trying to persist data from a microsoft web service call to a file when my app starts up. If the app is able to complete the webservice request, it's storing the data in an NSData object. Assuming the data has been successfully requested and stored, I want to execute...