Search Results

Search found 35 results on 2 pages for 'firstresponder'.

Page 1/2 | 1 2  | Next Page >

  • UITextFields firstResponder problem

    - by venkat
    hello all i am working with multiple uitextfields.i have a problem in cursor placing while changing firstResponder. i would like to do "Cursor placement in 2nd field once we entered the 3rd character in the 1st field." but the cursor stays in 3rd place.here i am restricting my first text field length to 3.

    Read the article

  • Nav Controller, UITableViewController, UITextField to become firstResponder?

    - by Daniel Granger
    I have a core data application which uses a navigation controller to drill down to a detail view and then if you edit one of the rows of data in the detail view you get taken to an Edit View for the that single line, like in Apples CoreDataBooks example! The edit view is a UITableviewController which creates its table with a single section single row and a UITextfield in the cell, programatically. What I want to happen is when you select a row to edit and the edit view is pushed onto the nav stack and the edit view is animated moving across the screen, I want the textfield to be selected as firstResponder so that the keyboard is already showing as the view moves across the screen to take position. Like in the Contacts app or in the CoreDataBooks App. I currently have the following code in my app which causes the view to load and then you see the keyboard appear (which isn't what I want, I want the keyboard to already be there) - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [theTextField becomeFirstResponder]; } You can't put this in -viewWillAppear as the textfield hasn't been created yet so theTextField is nil. In the CoreDataBooks App where they achieve what i want they load there tableview from a nib so they use the same code but in -viewWillAppear as the textfield has already been created! Is there anyway of getting around this without creating a nib, I want to keep the implementation programatic to enable greater flexibility. Many Thanks

    Read the article

  • Why does my NSWindow only receive mouseOver events the first time?

    - by DanieL
    I have an application where a borderless window is shown and hidden, using orderOut and orderFront. When it is visible, I want the it to become the key window when the mouse moves over it. So far I've done this: In awakeFromNib I have set its first responder to itself. In the window's constructor I set accepts mouse events to YES. In the mouseMoved method, I use makeKeyAndOrderToFront. My problem is, that this only works the first time I move the mouse over the window. After that, it doesn't receive any mouseOver events. I've tried checking the firstResponder but as far as I can tell it never changes from the window. Any ideas what I can do to get this working?

    Read the article

  • How to detect tap on uiview with lots of controls?

    - by kodcu
    My problem is about tap detection. I have a uiviewcontroller and there are some controls on uiview (labels, buttons, tableview, imageview, etc..) When I tap the uibutton I display a small uiview (200x150), if the user taps the uibuttons in smallview I hide the smallview. But I can't hide the uiview if the user taps the background. I tried this code.. -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ //NSLog(@"Touches began."); [self hideShareView]; } It doesn't work if I tap the another button in the uiviewcontrols view. I just want my uiviewcontrol's uiview to react first. I think its about firstResponder but I dont know how to set it first. edit: i want it to work like a uiPopover in ipad.

    Read the article

  • Can't Call resignFirstResponder from textFieldDidBeginEditing ? (iPhone)

    - by Chris
    [myTextField becomeFirstResponder]; [myTextField resignFirstResonder]; When I do this -(BOOL)textFieldShouldReturn:(UITextField *)textField , it works. But when I use the same code inside -(void)textFieldDidBeginEditing:(UITextField *)textField , it does not work. I am certain that it is calling textFieldDidBeginEditing. I have an NSLog inside the method and it is being called.

    Read the article

  • Need multiple views to respond to a touch event in an iPhone app

    - by Joel
    Setup: I have two views that I need to respond to the touch event, and they are layered out on top of one another. View 1 is on top of View 2. View 2 is a UIWebView. View 1 is sublclassed to capture the touch event. My problem is that if I try to call the UIWebView event handlers (touchesBegan: and touchesEnded:) from within the event handlers of View 1, which is the first responder, nothing happens. However if I set View 1 to userInteractionEnabled = NO, then the touch goes through that view and is processed properly by the 2nd view. Any ideas on how I can have 2 views respond to a touch event? Unfortunately the 2nd view is a UIWebView, so I need to actually call the event handler and not a different method, etc... Thanks in advance for any advice, Joel

    Read the article

  • keyDown works but i get beeps

    - by Oscar
    I just got my keydown method to work. But i get system beep everytime i press key. i have no idea whats wrong. Googled for hours and all people say is that if you have your keyDown method you should also implement the acceptsFirstResponder. did that to and it still doesn't work. #import <Cocoa/Cocoa.h> #import "PaddleView.h" #import "BallView.h" @interface GameController : NSView { PaddleView *leftPaddle; PaddleView *rightPaddle; BallView * ball; CGPoint ballVelocity; int gameState; int player1Score; int player2Score; } @property (retain) IBOutlet PaddleView *leftPaddle; @property (retain) IBOutlet PaddleView *rightPaddle; @property (retain) IBOutlet BallView *ball; - (void)reset:(BOOL)newGame; @end #import "GameController.h" #define GameStateRunning 1 #define GameStatePause 2 #define BallSpeedX 0.2 #define BallSpeedY 0.3 #define CompMoveSpeed 15 #define ScoreToWin 5 @implementation GameController @synthesize leftPaddle, rightPaddle, ball; - (id)initWithCoder:(NSCoder *)aDecoder { self = [super initWithCoder:aDecoder]; if(self) { gameState = GameStatePause; ballVelocity = CGPointMake(BallSpeedX, BallSpeedY); [NSTimer scheduledTimerWithTimeInterval:0.001 target:self selector:@selector(gameLoop) userInfo:nil repeats:YES]; } return self; } - (void)gameLoop { if(gameState == GameStateRunning) { [ball setFrameOrigin:CGPointMake(ball.frame.origin.x + ballVelocity.x, ball.frame.origin.y + ballVelocity.y)]; if(ball.frame.origin.x + 15 > self.frame.size.width || ball.frame.origin.x < 0) { ballVelocity.x =- ballVelocity.x; } if(ball.frame.origin.y + 35 > self.frame.size.height || ball.frame.origin.y < 0) { ballVelocity.y =- ballVelocity.y; } } if(CGRectIntersectsRect(ball.frame, leftPaddle.frame)) { if(ball.frame.origin.x > leftPaddle.frame.origin.x) { ballVelocity.x =- ballVelocity.x; } } if(CGRectIntersectsRect(ball.frame, rightPaddle.frame)) { if(ball.frame.origin.x +15 > rightPaddle.frame.origin.x) { ballVelocity.x =- ballVelocity.x; } } if(ball.frame.origin.x <= self.frame.size.width / 2) { if(ball.frame.origin.y < leftPaddle.frame.origin.y + 75 && leftPaddle.frame.origin.y > 0) { [leftPaddle setFrameOrigin:CGPointMake(leftPaddle.frame.origin.x, leftPaddle.frame.origin.y - CompMoveSpeed)]; } if(ball.frame.origin.y > leftPaddle.frame.origin.y +75 && leftPaddle.frame.origin.y < 700 - leftPaddle.frame.size.height ) { [leftPaddle setFrameOrigin:CGPointMake(leftPaddle.frame.origin.x, leftPaddle.frame.origin.y + CompMoveSpeed)]; } } if(ball.frame.origin.x <= 0) { player2Score++; [self reset:(player2Score >= ScoreToWin)]; } if(ball.frame.origin.x + 15 > self.frame.size.width) { player1Score++; [self reset:(player1Score >= ScoreToWin)]; } } - (void)reset:(BOOL)newGame { gameState = GameStatePause; [ball setFrameOrigin:CGPointMake((self.frame.size.width + 7.5) / 2, (self.frame.size.height + 7.5)/2)]; if(newGame) { if(player1Score > player2Score) { NSLog(@"Player 1 Wins!"); } else { NSLog(@"Player 2 Wins!"); } player1Score = 0; player2Score = 0; } else { NSLog(@"Press key to serve"); } NSLog(@"Player 1: %d",player1Score); NSLog(@"Player 2: %d",player2Score); } - (void)moveRightPaddleUp { if(rightPaddle.frame.origin.y < 700 - rightPaddle.frame.size.height) { [rightPaddle setFrameOrigin:CGPointMake(rightPaddle.frame.origin.x, rightPaddle.frame.origin.y + 20)]; } } - (void)moveRightPaddleDown { if(rightPaddle.frame.origin.y > 0) { [rightPaddle setFrameOrigin:CGPointMake(rightPaddle.frame.origin.x, rightPaddle.frame.origin.y - 20)]; } } - (BOOL)acceptsFirstResponder { return YES; } - (void)keyDown:(NSEvent *)theEvent { if ([theEvent modifierFlags] & NSNumericPadKeyMask) { NSString *theArrow = [theEvent charactersIgnoringModifiers]; unichar keyChar = 0; if ( [theArrow length] == 0 ) { return; // reject dead keys } if ( [theArrow length] == 1 ) { keyChar = [theArrow characterAtIndex:0]; if ( keyChar == NSLeftArrowFunctionKey ) { gameState = GameStateRunning; } if ( keyChar == NSRightArrowFunctionKey ) { } if ( keyChar == NSUpArrowFunctionKey ) { [self moveRightPaddleUp]; } if ( keyChar == NSDownArrowFunctionKey ) { [self moveRightPaddleDown]; } [super keyDown:theEvent]; } } else { [super keyDown:theEvent]; } } - (void)drawRect:(NSRect)dirtyRect { } - (void)dealloc { [ball release]; [rightPaddle release]; [leftPaddle release]; [super dealloc]; } @end

    Read the article

  • UITextfield is becoming focused after UIButton pressed

    - by Chris
    I have a UITextfield for entering text. A button triggers a functionality. After completion of the IBAction the UITextfield is getting focused again. After the IBAction I want to keyboard to disappear. What happends now is that due to the IBAction of the button, the keyboards disappears (I'm showing a UIAlert) and after the IBAction the keyboards pop's up again together with the focus in the UITextfield. Is it possible to prevent the UITextfield to be focused after the IBAction?

    Read the article

  • iPad keyboard will not dismiss if navigation controller presentation style is "form sheet".

    - by Kalle
    UPDATE: This is apparently "works as intended" classed by Apple. See accepted answer below for details. Update: this question is about a behavior discovered in the iPad keyboard, where it refuses to be dismissed if shown in a modal dialog with a navigation controller. Basically, if I present the navigation controller with the following line: navigationController.modalPresentationStyle = UIModalPresentationFormSheet; The keyboard refuses to be dismissed. If I comment out this line, the keyboard goes away fine. ... I've got two textFields, username and password; username has a Next button and password has a Done button. The keyboard won't go away if I present this in a modal navigation controller. WORKS broken *b = [[broken alloc] initWithNibName:@"broken" bundle:nil]; [self.view addSubview:b.view]; DOES NOT WORK broken *b = [[broken alloc] initWithNibName:@"broken" bundle:nil]; UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:b]; navigationController.modalPresentationStyle = UIModalPresentationFormSheet; navigationController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [self presentModalViewController:navigationController animated:YES]; [navigationController release]; [b release]; If I remove the navigation controller part and present 'b' as a modal view controller by itself, it works. Is the navigation controller the problem? WORKS broken *b = [[broken alloc] initWithNibName:@"broken" bundle:nil]; b.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [self presentModalViewController:b animated:YES]; [b release]; WORKS broken *b = [[broken alloc] initWithNibName:@"broken" bundle:nil]; UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:b]; [self presentModalViewController:navigationController animated:YES]; [navigationController release]; [b release];

    Read the article

  • keep keyboard open when deleting/inserting UITableView's cell (iphone)

    - by Jonathan
    I have a login form using a UITableView. One of the cells has a UISwitch which when on will delete the row above it and when off reinsert it. But the first cell automatically has the keyboard up when the cell is created (basically when the view loads) (by using [cell becomeFirstResponder];) Inserting/deleting any of the cells means that the keyboard animates out and then animates back in. I'd like to remove this so the keyboard stays up while rows are deleted/inserted.

    Read the article

  • How do I [legally] get the current first responder on the screen on an iPhone?

    - by Anthony D
    I submitted my app a little over a week ago and got the dreaded rejection email today. It reads as follows: Dear -----------, Thank you for submitting --------- to the App Store. Unfortunately it cannot be added to the App Store because it is using a private API. Use of non-public APIs, which as outlined in the iPhone Developer Program License Agreement section 3.3.1 is prohibited: "3.3.1 Applications may only use Documented APIs in the manner prescribed by Apple and must not use or call any private APIs." The non-public API that is included in your application is firstResponder. Regards, iPhone Developer Program Now, the offending API call is actually a solution I found here on SO: UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow]; UIView *firstResponder = [keyWindow performSelector:@selector(firstResponder)]; So this is my question; How do I get the current first responder on the screen? I'm looking for a legal way that won't get my app rejected. Thanks. I figured this out based on the solution provided by Thomas below. Here is what the final code looks like: @implementation UIView (FindFirstResponder) - (UIView *)findFirstResonder { if (self.isFirstResponder) { return self; } for (UIView *subView in self.subviews) { UIView *firstResponder = [subView findFirstResonder]; if (firstResponder != nil) { return firstResponder; } } return nil; } @end

    Read the article

  • iPhone simulator and applicationWillTerminate()

    - by firstresponder
    When my app is run in the iPhone simulator, the delegate method - (void)applicationWillTerminate:(UIApplication *)application is only called the first time I hit the iPhone simulator's home button. After the home button is pressed and the app is launched again, hitting the home button does not call the delegate method. What is going on here? Am I misunderstanding something fundamental?

    Read the article

  • willAnimateRotationToInterfaceOrientation not firing iphone UIInterfaceOrientation

    - by harekam_taj
    Hello, I have a view inside a tabbarcontroller and navigationcontroller and my willAnimateRotationToInterfaceOrientation method is not firing. I have set the view to be FirstResponder and also shouldAutorotateToInterfaceOrientation returning YES; - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { return YES; } -(BOOL)canBecomeFirstResponder { return YES; } [self becomeFirstResponder];

    Read the article

  • Another IKImageView Question: copying a region

    - by Brian Postow
    I'm trying to use the select and copy feature of the IKImageView. If all you want to do is have an app with an image, select a portion and copy it to the clipboard, it's easy. You set the copy menu pick to the first responder's copy:(id) method and magically everything works. However, if you want something more complicated, like you want to copy as part of some other operation, I can't seem to find the method to do this. IKImageView doesn't seem to have a copy method, it doesn't seem to have a method that will even tell you the selected rectangle! I have gone through Hillegass' book, so I understand how the clipboard works, just not how to get the portion of the image out of the view... Now, I'm starting to think that I made a mistake in basing my project on IKImageView, but it's what Preview is built on (or so I've read), so I figured it had to be stable... and anyway, now it's too late, I'm too deep in this to start over... So, other than not using IKImageView, any suggestions on how to copy the select region to the clipboard manually? EDIT actually, I have found the copy(id) method, but when I call it, I get <Error>: CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/component; 16 bits/pixel; 1-component color space; kCGImageAlphaPremultipliedLast; 2624 bytes/row. Which obviously doesn't happen when I do a normal copy through the first-responder... I understand the error message, but I'm not sure where it's getting those parameters from... Is there any way to trace through this and see how this is happening? A debugger won't help for obvious reasons, as well as the fact that I'm doing this in Mozilla, so a debugger isn't an option anyway... EDIT 2 It occurs to me that the copy:(id) method I found may be copying the VIEW rather than copying a chunk of the image to the clipboard, which is what I need. The reason I thought it was the clipboard copy is that in another project, where I'm copying from an IKImageView to the clipboard straight from the edit menu, it just sends a copy:(id) to the firstResponder, but I'm not actually sure what the firstresponder does with it...

    Read the article

  • How we set or get focus to any control - and leave the focus in COCOA

    - by Amit Battan
    Hi All How we set or get focus on any control in cocoa. like setfirstresponder We have 2 control A and B, A is firstresponder After action I want to set focus ob B control and also how we get focus on a particular control and how we notify that leave focus..... I need it in validation .... I want to force user to fill a textfield and then go to next field..something like this Thanks Deepika

    Read the article

  • iPhone App rejected because of Three20 private API undocumented, private UITouch instance variables:

    - by Sijo
    I got a notification mail after submitting to app store.. "During our review of your application we found it is using private APIs, which is in violation of the iPhone Developer Program License Agreement section 3.3.1; "3.3.1 Applications may only use Documented APIs in the manner prescribed by Apple and must not use or call any private APIs." While your application has not been rejected, it would be appropriate to resolve this issue in your next update. The non-public APIs that are included in your application are the following undocumented, private UITouch instance variables: firstResponder UITouch._locationInWindow UITouch._phase UITouch._previousLocationInWindow UITouch._tapCount UITouch._timestamp UITouch._touchFlags UITouch._view UITouch._window Please resolve this issue in your next update to Application " . My application contains Three20. These variables are used in "UIViewAdditions.m". Is there any way to resolve this issue ? Please help me. Thanks in advance

    Read the article

  • UITextView text disappear

    - by user153412
    Hi, i create an uitextview dynamically then i write my text into it. Sometime, when i create the uitextview, the cursor disappear and i see no text in it. If i run the application again, i can see the text inside the textview that i've created before. I've tried to set the cursor position to zero or scroll the text to the top but it doesn't work... Any suggestion? Here is a screen capture. You can see the gray uitextview, the keyboard (the textview is the firstresponder) but no cursor or text. http://yfrog.com/hqschermata20100325a11213p PS: i'm sorry for my bad english.

    Read the article

  • deriving from NSTabViewItem

    - by Jonny
    I'm writing a Cocoa app. One dialog has 3 tabs, some of the tabs needs more loading time, so I want to load them lazily. Since each Tab is a NSTabViewItem class, so I'm trying to derive from it and overriding its view property. In the view getter method, I use a ViewController to load a view and returns out. In Debugging, I found NSTabViewItem -view method is get called correctly, but after that NSTabView tries to set Initial FirstResponder and crashed with message: * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'In -[NSTabViewItem setInitialFirstResponder:], the first responder must descend from the tab view item's view. (Item: Invalid responder: )' I tried to override the -initialFirstResponder method to return a sub-view of my loaded view, but it still crashes the same place. does anyone know how to get it work correctly? Also is it correct way to do this by deriving the NSTabViewItem? thanks! -Jonny

    Read the article

  • UITextInput setMarkedText:selectedRange not working? (Can't be!)

    - by nacho4d
    I want to set the marked text programmatically and since iOS5 UITextView and UITextField conform to UITextInput this should be possible but for some reason I always get the markedText to be nil. :( What am I missing here? This is what I've tried without success: (While the textview is firstResponder) 1.- When the text view contains no text: text: "", selectedRange : {0,0}, markedText: nil. [_textView setMarkedText:@"?" selectedRange:NSMakeRange(0, 1)]; Result: text : "", selectedRange: {0,0}, markedText: nil. (Nothing changed) 2.- When the text view contains text + some marked text: text : "AAA", selectedRange = {0,3}, marked text at the end : "??" then I do: [_textView setMarkedText:@"?" selectedRangeNSMakeRange(0,3)]; Result : text :"AAA", selectedRange: {0,3}, markedText: nil; (the marked text became nil) In both cases is like setMarkedText:selectedRange: would be setting the current marked text (if some) to nil. Any help would be highly appreciated :)

    Read the article

  • Bring to front DatePicker on an UITextField

    - by crazyfr
    Hi, When an UITextField is firstResponder, I would like to bring to front an UIDatePicker (bottom part of the screen) without the "going down keyboard" (no call to UITextField resignFirstResponder). The aim is to process like UIKeyboard of UITextField which pop-up on nearly everything when it becomeFirstResponder. modalViewController seems to be fullscreen only. - showDatePicker:(id)sender { if([taskName isFirstResponder]) [taskName resignFirstResponder]; [self.view.window addSubview: self.pickerView]; // size up the picker view and compute the start/end frame origin (...) [UIView commitAnimations]; } This example is an animation of keyboard going down, and DatePicker going up, behind and not in front. Do you know a solution ? A piece of code would be welcome. Thanks in advance.

    Read the article

  • Scrolling png with text & alpha on top of a static UIImageView

    - by heymon
    I have a view controller that has a view structure as follows: FilesOwner FirstResponder View ImageView (.jpg) ScrollView ImageView (.png) The text in the innermost imageview has white text and clear (alpha) all around. I want to scroll the innermost imageview, and see the background image (the .jpg) behind it. Its not working. Its acting like the scrollview background obscures the underneath .jpg. I say this because if I change the background color of the scrollview, that's what I see i.e. if I set it black, I see black behind my .png, if I set it white, I see white. If I change the alpha of the scrollview that doesn't seem to work either. The one other thing I tried was unchecking drawing: Opaque, but that doesn't get it either.

    Read the article

  • iPhone UIWebView becomeFirstResponder

    - by user505618
    I have an UIWebView with an <input type="text"/> html element in it. I want to focus the input element in the html and show the keyboard on the iPhone programmatically, without tapping the screen. I've tried the following: set the focus from JavaScript (in this case the onFocus JS event will fire but the keyboard won't show up) [webView becomeFirstresponder] (returns NO) set the first subview of the webView to be the firstResponder (returns NO) subclass UIWebView to return YES to canBecomeFirstResponder: (nothing happens) I'm trying to find the solution since yesterday but I couldn't find it. Please help.

    Read the article

  • Can't resignFirstResponder with UITextView

    - by Calvin L
    I have a UITextView. I implemented a navigationBar UIBarButtonItem to respond to a touch and resign the firstResponder for my UITextView. But, when the selector method is called, the keyboard doesn't get dismissed. I checked the UITextView's responder status with isFirstResponder and it returns YES. I also checked it with canResignFirstResponder and the return value is NO. I must be missing something here...why is it returning NO? I get that I can override canResignFirstResponder by subclassing UITextView, but I'd like to avoid that if possible. Here's a code snippet: - (void) commentCancelButtonTouched:(id)sender { NSLog(@"Cancel button touched"); [self.navigationBar popNavigationItemAnimated: NO]; if ([self.textInput.textView canResignFirstResponder] == NO) { NSLog(@"I don't want to resign!"); } [self.textInput.textView resignFirstResponder]; }

    Read the article

  • Adding an NSTextField as a subview

    - by Kenny
    I'm trying to add an NSTextField as a subview of a custom view class I have (which subclasses NSView), and then make the text field the first responder. This works fine... the text field shows up and I can start typing in it. However, any mouse events in the text field seem to fall through to its superview. For example, I can't see the mouse cursor when I hover over the text field, and when I click anywhere in the text field, it attempts to resign firstResponder status instead of letting me select text within the text field. I'm not overridding hitTest or anything weird like that, and I only have one window, which is definitely the key window. Any ideas? Thanks in advance! :-)

    Read the article

1 2  | Next Page >