Search Results

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

Page 2/2 | < Previous Page | 1 2 

  • Communicating between classes set up in nib, in code?

    - by cannyboy
    A beginner's question: If, in your nib, you have the File's Owner linked to the ViewController class, and you also have a NSObject-derived class, how do you communicate between the ViewController class and the NSObject class within code? For instance, suppose ScientificCalculatorView.xib looks like this File's Owner (class: ScientificCalculatorViewController) FirstResponder View Calculator (an object that has been linked to the Calculator class) Obviously, I'd want Calculator to be reusable, so it could be used with a NormalCalculatorViewController or something like that. So that UI and the calculator code are separate. Does Calculator even need to be in the nib? It's a beginners question, but I'm just trying to get my head around it.

    Read the article

  • Displaying menus on image

    - by Snehal
    Hi all, Here is what i am doing: I have a viewcontroller screen1 to which I have added long press gesture. On longPress, user will get draw menu. On selecting that menu, i am creating another uiviewcontroller class object which has a rectangle image. This instance i am adding as a subview to screen1. Now what i want is that once the image is displayed on the screen1, i want to display UImenuItems Done and cancel above the image drawn so that on tapping on done menu, the image is saved. I tried making the new viewcontroller as firstResponder after adding image to screen1 but the menus are not visible. Any one please help

    Read the article

  • Create an Edit view similar to Contacts App

    - by Daniel Granger
    I have an edit view in my app which is a instance of UITableViewController and contains one cell with a textfield in a grouped table. At the moment this cell is at the top of the screen and is firstResponder so they keyboard is visible as well. But in all the Apples apps like the Contacts App when you edit a piece of information like an Email it buts both of its rows in the middle between the Nav Bar and the Keyboard not at the top of the screen. How do I achieve this effect? Many Thanks

    Read the article

  • EXC_BAD_ACCESS iPhone Development

    - by gkres121
    Sorry, this could be a simple fix, as I am new to iPhone Development. In my Delegate, after pressing the create profile button, the create profile view is pushed: -(void) createProfile_clicked:(id)sender { AddNewProfile *create = [[AddNewProfile alloc] init]; [self.window addSubview:create.view]; [self invisibleCreateProfileBar]; AddNewProfile *controller = [[AddNewProfile alloc] initWithNibName:@"AddNewProfile" bundle:[NSBundle mainBundle]]; [ self.navigationController pushViewController:controller animated:YES ]; currentController=controller; } Then in the AddNewProfile.m: - (IBAction)backgroundTap:(id)sender { if([nameField isFirstResponder]){ [nameField resignFirstResponder]; } if([ageField isFirstResponder]){ [ageField resignFirstResponder]; } if([doctorNameField isFirstResponder]){ [doctorNameField isFirstResponder]; } if([doctorNumberField isFirstResponder]){ [doctorNumberField resignFirstResponder]; } } This leads to a exc_bad_access error every time the FirstResponder is ever messed with, with any of my controls. I can select a control(text box), but once I click out of one, it crashes. Any help would be greatly appreciated.

    Read the article

  • - (void)keyboardWasShown not called when switching to another UITextField

    - by Shawn
    I'm having a strange problem that I don't understand. I have a UIScrollView with several UITextField objects. When I switch to the view, I set the first UITextField as firstresponder, and the keyboardWasShown method gets called due to the UIKeyboardDidShowNotification that the view is registered for. The weird thing is, when I touch the next UITextField, the keyboardWasShown method is not called. I don't understand this, since Apple's documentation says "If your interface has multiple text fields, the user can tap between them to edit the values in each one. When that happens, however, the keyboard does not disappear but the system does still generate UIKeyboardDidShowNotification notifications each time editing begins in a new text field." My code I've copied directly from Apple's documentation as well, and it works properly, but it only gets called the first time. What am I missing? - (void)registerForKeyboardNotifications { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWasShown:) name:UIKeyboardDidShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWasHidden:) name:UIKeyboardDidHideNotification object:nil]; } - (void)keyboardWasShown:(NSNotification *)aNotification { //if (keyboardShown) return; NSDictionary* info = [aNotification userInfo]; CGSize kbSize = [[info objectForKey:UIKeyboardBoundsUserInfoKey] CGRectValue].size; CGRect bkgndRect = activeField.superview.frame; bkgndRect.size.height += kbSize.height; [activeField.superview setFrame:bkgndRect]; [scrollView setContentOffset:CGPointMake(0.0, activeField.frame.origin.y) animated:YES]; keyboardShown = YES; UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(done)]; self.navigationItem.rightBarButtonItem = doneButton; [doneButton release]; }

    Read the article

  • Using iphone accelerometer AND UIEventSubtypeMotionShake event simultaneousluy.

    - by lukya
    Hi, I am using accelerometer to move/change things on the screen in my app. I also need to detect UIEventSubtypeMotionShake in the view controller for some other animations. As my app is a simple view based app, there is just one view controller which acts as UIAccelerometerDelegate AND FirstResponder (for detecting the shake event). After the first Shake gesture is detected, I don’t need accelerometer inputs through [accelerometer didAccelerate] method so I set the accelerometer delegate to nil. -(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event { if (motion == UIEventSubtypeMotionShake) { NSLog(@"shake"); [[UIAccelerometer sharedAccelerometer] setDelegate:nil]; //my shake handling code } } The problem is that the first shake motion is not being detected correctly. I have to shake 2 3 or more times to trigger the UIEventSubtypeMotionShake event, while the subsequent shakes, after the accelerometer delegate is made nil, are being detected perfectly. This must be happening because UIEventSubtypeMotionShake in turn depends on the accelerometer didAccelerate events which are being overridden by my code. But I need to use both the events. Are there any apps or code samples which use both accelerometer and UIEventSubtypeMotionShake simultaneously? Thanks Swapnil

    Read the article

  • UITextField inside of UITableViewCell will not activate on iPad but works on iPhone

    - by cfihelp
    I have a UITextField inside a UITableViewCell. It will not activate on the iPad (but it works fine on the iPhone) no matter what I try. Tapping on it and telling it to become the firstResponder both fail. The odd thing is that if I take the exact same code and move it to another view controller in my app it executes just fine. This makes it seem as if there is likely a problem in the parent UITableViewController but I can't find anything obvious. I'm hoping that someone out there has experienced a similar problem and can point me in the right direction. Below is the sample code that works fine when I move it to a new project or put it in a new view controller launched immediately by my app delegate: // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } if (indexPath.row == 0) { UITextField *nameText = [[UITextField alloc] initWithFrame:CGRectMake(5, 5, cell.contentView.frame.size.width, cell.contentView.frame.size.height)]; nameText.delegate = self; nameText.backgroundColor = [UIColor redColor]; [cell.contentView addSubview:nameText]; [nameText becomeFirstResponder]; [nameText release]; } // Configure the cell... return cell; } Help!

    Read the article

  • Calling method on category included from iPhone static library causes NSInvalidArgumentException

    - by Corey Floyd
    I have created a static library to house some of my code like categories. I have a category for UIViews in "UIView-Extensions.h" named Extensions. In this category I have a method called: - (void)fadeOutWithDelay:(CGFloat)delay duration:(CGFloat)duration; Calling this method works fine on the simulator on Debug configuration. However, if try to run the app on the device I get a NSInvalidArgumentException: [UIView fadeOutWithDelay:duration:]: unrecognized selector sent to instance 0x1912b0 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIView fadeOutWithDelay:duration:]: unrecognized selector sent to instance 0x1912b0 It seems for some reason UIView-Extensions.h is not being included in the device builds. What I have checked/tried I did try to include another category for NSString, and had the same issue. Other files, like whole classes and functions work fine. It is an issue that only happens with categories. I did a clean all targets, which did not fix the problem. I checked the static library project, the categories are included in the target's "copy headers" and "compile sources" groups. The static library is included in the main projects "link binary with library" group. Another project I have added the static library to works just fine. I deleted and re-added the static library with no luck -ObjC linker flag is set Any ideas? nm output libFJSCodeDebug.a(UIView-Extensions.o): 000004d4 t -[UIView(Extensions) changeColor:withDelay:duration:] 00000000 t -[UIView(Extensions) fadeInWithDelay:duration:] 000000dc t -[UIView(Extensions) fadeOutWithDelay:duration:] 00000abc t -[UIView(Extensions) firstResponder] 000006b0 t -[UIView(Extensions) hasSubviewOfClass:] 00000870 t -[UIView(Extensions) hasSubviewOfClass:thatContainsPoint:] 000005cc t -[UIView(Extensions) rotate:] 000002d8 t -[UIView(Extensions) shrinkToSize:withDelay:duration:] 000001b8 t -[UIView(Extensions) translateToFrame:delay:duration:] U _CGAffineTransformRotate 000004a8 t _CGPointMake U _CGRectContainsPoint U _NSLog U _OBJC_CLASS_$_UIColor U _OBJC_CLASS_$_UIView U ___CFConstantStringClassReference U ___addsf3vfp U ___divdf3vfp U ___divsf3vfp U ___extendsfdf2vfp U ___muldf3vfp U ___truncdfsf2vfp U _objc_enumerationMutation U _objc_msgSend U _objc_msgSend_stret U dyld_stub_binding_helper

    Read the article

  • NSTableView selection & highlights

    - by Christian
    I have a NSTableView as a very central part of my Application and want it to integrate more with the rest of it. It has only one column (it's a list) and I draw all Cells (normal NSTextFieldCells) myself. The first problem is the highlighting. I draw the highlight myself and want to get rid of the blue background. I now fill the whole cell with the original background color to hide the blue background, but this looks bad when dragging the cell around. I tried overriding highlight:withFrame:inView: and highlightColorWithFrame:inView: of NSCell but nothing happened. How can I disable automatic highlighting? I also want all rows/cells to be deselected when I click somewhere outside my NSTableView. Since the background / highlight of the selected cell turns gray there must be an event for this, but I can't find it. I let my cells expand on a double click and may need to undo this. So getting rid of the gray highlight is not enough. EDIT: I add a subview to the NSTableView when a cell gets double clicked and then resignFirstResponder of the NSTableView gets called. I tried this: - (BOOL)resignFirstResponder { if (![[self subviews] containsObject:[[self window] firstResponder]]) { [self deselectAll:self]; ... } return YES; } Besides that it's not working I would need to implement this method for all objects in the view hierarchy. Is there an other solution to find out when the first responder leaves a certain view hierarchy?

    Read the article

  • Properly setting up willSelectRowAtIndexPath and didSelectRowAtIndexPath to send cell selections

    - by Gordon Fontenot
    Feel like I'm going a bit nutty here. I have a detail view with a few stand-alone UITextFields, a few UITextFields in UITAbleViewCells, and one single UITableViewCell that will be used to hold notes, if there are any. I only want this cell selectable when I am in edit mode. When I am not in edit mode, I do not want to be able to select it. Selecting the cell (while in edit mode) will fire a method that will init a new view. I know this is very easy, but I am missing something somewhere. Here are the current selection methods I am using: -(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (!self.editing) { NSLog(@"Returning nil, not in edit mode"); return nil; } NSLog(@"Cell will be selected, not in edit mode"); if (indexPath.section == 0) { NSLog(@"Comments cell will be selected"); return indexPath; } return nil; } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (!self.editing) { NSLog(@"Not in edit mode. Should not have made it this far."); return; } if (indexPath.section == 0) [self pushCommentsView]; else return; } My problem is really 2 fold; 1) Even when I'm not in edit mode, and I know I am returning nil (due to the NSLog message), I can still select the row (it flashes blue). From my understanding of the willSelectRowAtIndexPath method, this shouldn't be happening. Maybe I am wrong about this? 2) When I enter edit mode, I can't select anything at all. the willSelectRowAtIndexPath method never fires, and neither does the didSelectRowAtIndexPath. The only thing I am doing in the setEditing method, is hiding the back button while editing, and assigning firstResponder to the top textField to get the keyboard to pop up. I thought maybe the first responder was getting in the way of the click (which would be dumb), but even with that commented out, I cannot perform the cell selection during editing.

    Read the article

< Previous Page | 1 2