Tag: events

Simulate touch on iphone

Im trying to simulate a touch on as UIWebView, how can I programmatically fire a touch event at a certain location? (x and y coordinates) Just call touchesBegan? Ideally I’d like to do it without any javascript hack because in the future it may not be a uiwebview

Get 'Touch Drag Inside' Distance When Setting IBAction From Storyboard

I know how to set UIPanGesture events and recognizers and get the data I need when I create them programatically. However I am trying to learn how to work with the storyboard and use IBOutlets. I have dragged over an IBAction for ‘Touch Drag Inside’. @IBAction func dragButtonDragEvent(sender: AnyObject) { println(sender) } The problem is […]

Get keyDown event for an NSTextField

In xcode last version, I am trying to get the keyDown event of an NSTextField. However, despite following multiple tutorials on the internet (delegates, controllers…), I still can’t receive it. Any easy hint for me ? Thanks !

Weird swift interpolation error: Could not find member 'convertFromStringInterpolationSegment'

I get a weird error when I try to use swift‘s interpolation in the following code: override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { var alert = UIAlertController(title: “Clicked!”, message:”You clicked row # \(indexPath.row)”, preferredStyle: UIAlertViewStyle.Default); } I haven’t finished the alert view yet, but I don’t think thats the cause of the error. Its […]

How to simulate a continuous key press

I need to simulate a continuous key press. For example hold down the ‘c’ key for 5 seconds. To simulate a key press event I tried to use CGEventCreateKeyboardEvent: let event:CGEventRef! = CGEventCreateKeyboardEvent(nil, 8, true) CGEventPost(CGEventTapLocation.CGSessionEventTap, event) But it acts like if the button is tapped and then released immediately. I need to create an […]

Swift – UITableView scroll event

I was wondering how to detect if the UITableView is scrolled (up or down). I want to hide the keyboard when the UITableView is scrolled with self.view.endEditing(true). Thanks in advance

Cancel a timed event in Swift?

I want to run a block of code in 10 seconds from an event, but I want to be able to cancel it so that if something happens before those 10 seconds, the code won’t run after 10 seconds have gone by. I’ve been using this, but it’s not cancellable: static func delay(delay:Double, closure:()->()) { […]

Passing touch events to appropriate sibling UIViews

I’m trying to handle touch events with touchesBegan in an overlay to a parent UIView but also allow the touch input to pass through to sibling UIViews underneath. I expected there would be some straight-forward way to process a touch event and then say “now send it to the next responder as if this one […]

EKEvent with eventWithIdentifier on iOS

If I want to retrieve EKEvent from EKEventStore with eventWithIdentifier method for previously saved event but I always get null. This is the code for adding event: EKEventStore *eventStore = [[EKEventStore alloc] init]; EKEvent *newEvent = [EKEvent eventWithEventStore:eventStore]; newEvent.title = @”Test”; newEvent.availability = EKEventAvailabilityFree; newEvent.startDate = startDate; newEvent.endDate = endDate; [newEvent addAlarm:[EKAlarm alarmWithRelativeOffset:-15*60]]; newEvent.calendar = […]

Set focus to UITextField in tableCell

I am creating a table view with UITextFields dynamically. l_textField = [[UITextField alloc] initWithFrame:TextFieldFrame]; l_textField.tag = cellRow; l_textField.delegate = self; l_textField.font = [UIFont boldSystemFontOfSize:14]; l_textField.textColor = [UIColor blackColor]; [l_textField setEnabled:YES]; [cell.contentView addSubview:l_textField]; And now I want to set focus on this text field when user touch cell. I write this – (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)newIndexPath […]