Search Results

Search found 295 results on 12 pages for 'uitextfield'.

Page 7/12 | < Previous Page | 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How do I prevent my table cell's textview from being editable after editing is done?

    - by Gorgando
    So this is an interesting problem. I have custom tableviewcells that include a text field. When In my cellForRowAtIndexPath I have an if statement that determines whether or not the cell's text field should be editable- it looks like this: (self.isEditing) ? [infoCell.textField setEnabled:YES] : [infoCell.textField setEnabled:NO]; This actually works well - except for the issue I'm having. It makes it so that when the tableview is displayed, the rows' text field cannot be edited. When the user clicks "Edit" to put it into editing mode, then the text fields are enabled for editing. The Problem: When I am editing a field, and click "Done", it goes back to the regular tableview but the keyboard stays visible and the last cell's text field I was editing continues to be editable. What Should happen: The keyboard should go away and all the cells' text fields should no longer be editable. Any ideas about what could be going wrong? Things to look for? Thanks!

    Read the article

  • Static keyboard in uitableview

    - by Martin
    I have a UITableView that holds just two cells with a textfield in each. As my tableview is just for editing the text in these textfields I always want the keyboard to be shown static in the bottom of the screen. So in viewDidLoad I set the first textfield to become first responder. Something I have noticed though is that when I push the UITableViewController into the UINavigationController the keyboard show up a little bit slower so you can see it animate into the screen. It would be much better if it was there already there when the uitableview shows up. I also tried making the textfield first responder before pushing it as recommended but that didn't made the keyboard show at all: MyTableViewController *myTableViewController = [[MyTableViewController alloc] initWithNibName:@"MyTableViewController" bundle:nil]; [myTableViewController.textField becomeFirstResponder]; [self.navigationController pushViewController:myTableViewController animated:YES]; [myTableViewController release]; How can I accomplish this? Thanks!

    Read the article

  • UITextField for Phone Number

    Hello everyone, I was wondering how I can format the textField that I'm using for a phone number (ie like the "Add New Contact" page on the iPhone. When I enter in a new mobile phone, ex. 1236890987 it formats it as (123) 689-0987.) I already have the keyboard set as the number pad. Thanks!

    Read the article

  • Problem getting textfield.text from other view controller

    - by wesleydyson
    Hey guys, I'm trying to add a textfield.text entry to an array. I want to pull the textfield.text from a text field in another view. Here's my code. - (void)addBookmark{ MultiViewViewController *mainView = [[MultiViewViewController alloc] init]; if (mainView.addressTextField.text.length>1) { NSString *addedString = [[NSString alloc] initWithFormat:@"%@", mainView.addressTextField.text]; [bookmarksArray addObject:addedString]; NSLog(@"addBookmark being called %@", mainView.addressTextField.text); } [bmTableView reloadData]; } The NSLog says the mainView.addressTextField.text is (NULL). What am I doing wrong?

    Read the article

  • iPhone keyboard's return key will move curser to next textfield

    - by iAm
    Hello Fellow Koder ••• I have a TableViewController that is using a grouped Style and has two(2) sections. The first section has 4 rows and the second section has 3 rows. I have placed a UILabel and a UITextField in each cell, and have a custom method(textFieldDone:) to handle the cursor movement to the next text field when the return key is press. This works fine and dandy if there is only one section, but I have two :( and yes I need two:) so I started koden' up an answer, but got results that just don't work, I did notice during my debugging that cell Identifier (I use Two) is only showing the one (in the debug consol) and it's the first one only (Generic Cell). - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = nil; switch (indexPath.section) { case AUTO_DETAILS: { static NSString *cellID = @"GenericCell"; cell = [tableView dequeueReusableCellWithIdentifier:cellID]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:cellID] autorelease]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 75, 25)]; label.tag = kLabelTag; label.font = [UIFont boldSystemFontOfSize:14]; label.textAlignment = UITextAlignmentRight; [cell.contentView addSubview:label]; [label release]; UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(90, 12, 200, 25)]; textField.clearsOnBeginEditing = NO; [textField setDelegate:self]; [textField addTarget:self action:@selector(topTextFieldDone:) forControlEvents:UIControlEventEditingDidEndOnExit]; [cell.contentView addSubview:textField]; } NSInteger row = [indexPath row]; UILabel *label = (UILabel *)[cell viewWithTag:kLabelTag]; UITextField *textField = nil; for (UIView *oneView in cell.contentView.subviews) { if ([oneView isMemberOfClass:[UITextField class]]) textField = (UITextField *)oneView; } label.text = [topCellLabels objectAtIndex:row]; NSNumber *rowAsNum = [[NSNumber alloc] initWithInt:row]; switch (row) { case kMakeRowIndex: if ([[tempValues allKeys] containsObject:rowAsNum]) textField.text = [tempValues objectForKey:rowAsNum]; else textField.text = automobile.make; break; case kModelRowIndex: if ([[tempValues allKeys] containsObject:rowAsNum]) textField.text = [tempValues objectForKey:rowAsNum]; else textField.text = automobile.model; break; case kYearRowIndex: if ([[tempValues allKeys] containsObject:rowAsNum]) textField.text = [tempValues objectForKey:rowAsNum]; else textField.text = automobile.year; break; case kNotesRowIndex: if ([[tempValues allKeys] containsObject:rowAsNum]) textField.text = [tempValues objectForKey:rowAsNum]; else textField.text = automobile.notes; break; default: break; } if (textFieldBeingEdited == textField) { textFieldBeingEdited = nil; } textField.tag = row; [rowAsNum release]; break; } case AUTO_REGISTRATION: { static NSString *AutoEditCellID = @"AutoEditCellID"; cell = [tableView dequeueReusableCellWithIdentifier:AutoEditCellID]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:AutoEditCellID] autorelease]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 75, 25)]; label.tag = kLabelTag; label.font = [UIFont boldSystemFontOfSize:14]; label.textAlignment = UITextAlignmentRight; [cell.contentView addSubview:label]; [label release]; UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(90, 12, 200, 25)]; textField.clearsOnBeginEditing = NO; [textField setDelegate:self]; [textField addTarget:self action:@selector(bottomTextFieldDone:) forControlEvents:UIControlEventEditingDidEndOnExit]; [cell.contentView addSubview:textField]; } NSInteger row = [indexPath row]; UILabel *label = (UILabel *)[cell viewWithTag:kLabelTag]; UITextField *textField = nil; for (UIView *oneView in cell.contentView.subviews) { if ([oneView isMemberOfClass:[UITextField class]]) textField = (UITextField *)oneView; } label.text = [bottomCellLabels objectAtIndex:row]; NSNumber *rowAsNum = [[NSNumber alloc] initWithInt:row]; switch (row) { case 0: if ([[tempValues allKeys] containsObject:rowAsNum]) textField.text = [tempValues objectForKey:rowAsNum]; else textField.text = automobile.vinNumber; break; case 1: if ([[tempValues allKeys] containsObject:rowAsNum]) textField.text = [tempValues objectForKey:rowAsNum]; else textField.text = automobile.policyNumber; break; case 2: if ([[tempValues allKeys] containsObject:rowAsNum]) textField.text = [tempValues objectForKey:rowAsNum]; else textField.text = automobile.licensePlate; break; default: break; } if (textFieldBeingEdited == textField) { textFieldBeingEdited = nil; } textField.tag = row; [rowAsNum release]; break; } default: break; } return cell; } Now remember that the first section is working fine and the kode for that method is this: -(IBAction)topTextFieldDone:(id)sender { UITableViewCell *cell = (UITableViewCell *)[[sender superview] superview]; UITableView *table = (UITableView *)[cell superview]; NSIndexPath *textFieldIndexPath = [table indexPathForCell:cell]; NSUInteger row = [textFieldIndexPath row]; row++; if (row > kNumOfEditableRows) row = 0; NSUInteger newIndex[] = {0, row}; NSIndexPath *newPath = [[NSIndexPath alloc] initWithIndexes:newIndex length:2]; UITableViewCell *nextCell = [self.tableView cellForRowAtIndexPath:newPath]; UITextField *nextField = nil; for (UIView *oneView in nextCell.contentView.subviews) { if ([oneView isMemberOfClass:[UITextField class]]) nextField = (UITextField *)oneView; } [nextField becomeFirstResponder]; } It was my idea to just create a second method (secondSectionTextFieldDone:) like this -(IBAction)bottomTextFieldDone:(id)sender { UITableViewCell *cell = (UITableViewCell *)[[sender superview] superview]; UITableView *table = (UITableView *)[cell superview]; NSIndexPath *textFieldIndexPath = [table indexPathForCell:cell]; NSUInteger row = [textFieldIndexPath row]; row++; if (row > 3) row = 0; NSUInteger newIndex[] = {0, row}; NSIndexPath *newPath = [[NSIndexPath alloc] initWithIndexes:newIndex length:2]; UITableViewCell *nextCell = [self.tableView cellForRowAtIndexPath:newPath]; UITextField *nextField = nil; NSString *string = [NSString stringWithFormat:@"AutoEditCellID"]; for (UIView *oneView in nextCell.contentView.subviews) { NSLog(@"%@", nextCell.reuseIdentifier); /* DEBUG LOG */ if ([oneView isMemberOfClass:[UITextField class]] && (nextCell.reuseIdentifier == string)) nextField = (UITextField *)oneView; } [nextField becomeFirstResponder]; } but the result does not solve the issue. so my question is, how can i get the cursor to jump to the next textfield in the section that it is in, If there is one, and if not, then send a message "resignFirstResponder" so that, the keyboard goes away.

    Read the article

  • iPhone app. Creating a custom UIView that contains UITextField and UIButton.

    - by Dmitry Burchik
    Hi all. I am new to iPhone programming. And I have an issue. I need to create a custom user control that I will add to my UIScrollView dinamically. The control has an UITextField and an UIButton. See the code below: #import <UIKit/UIKit.h> @interface FieldWithValueControl : UIView { UITextField *txtTagName; UIButton *addButton; } @property (nonatomic, readonly) UITextField *txtTagName; @property (nonatomic, readonly) UIButton *addButton; @end #import "FieldWithValueControl.h" #define ITEM_SPACING 10 #define ITEM_HEIGHT 20 #define SWITCHBOX_WIDTH 100 #define SCREEN_WIDTH 320 #define ITEM_FONT_SIZE 14 #define TEXTBOX_WIDTH 150 @implementation FieldWithValueControl @synthesize txtTagName; @synthesize addButton; - (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { // Initialization code txtTagName = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, TEXTBOX_WIDTH, ITEM_HEIGHT)]; txtTagName.borderStyle = UITextBorderStyleRoundedRect; addButton = [UIButton buttonWithType:UIButtonTypeContactAdd]; [addButton setFrame:CGRectMake(ITEM_SPACING + TEXTBOX_WIDTH, 0, ITEM_HEIGHT, ITEM_HEIGHT)]; [addButton addTarget:self action:@selector(addButtonTouched:) forControlEvents:UIControlEventTouchUpInside]; [self addSubview:txtTagName]; [self addSubview:addButton]; } return self; } - (void)addButtonTouched:sender { UIButton *button = (UIButton*)sender; NSString *title = [button titleLabel].text; } - (void)drawRect:(CGRect)rect { // Drawing code } - (void)dealloc { [txtTagName release]; [addButton release]; [super dealloc]; } @end In my code I create an object of that class and add it to scrollView on form. FieldWithValueControl *newTagControl = (FieldWithValueControl*)[[FieldWithValueControl alloc] initWithFrame:CGRectMake(ITEM_SPACING, currentOffset + ITEM_SPACING, 0, 0)]; [scrollView addSubview:newTagControl]; The control looks fine, but if I click to the textbox or to the button nothing happens. Keyboard doesn't appear, the button is not clickable etc.

    Read the article

  • How to avoid keyboard hide & show when focus changes from UITextField and UIWebView?

    - by Manoj
    I have a requirement in which the view contains one native UITextField and one UIWebView. The issue is if I switch the focus from UITextView to UIWebView, the keyboard window flicker(hides and then shows). ie, I got UIKeyboardWillHideNotification and UIKeyboardDidShowNotification But, this is not happening when I switch the other way. ies, I got only UIKeyboardDidShowNotification Is there any way to avoid this flickering effect? Note: I also notices if I have multiple UITextField and UIWebView, this issue is not happening with the same type of views.

    Read the article

  • Where is my object allocation and memory leak in this iPhone/objective C code?

    - by Spottswoode
    Hello, I'm still a rookie when it comes to this programming gig and was wondering if someone could help me smooth out this code. Functionally, the code works great and does what I need it to do. But when I run the performance tool the allocation graph peaks, the CPU load is high, there's a leak(s), and I've also confirmed when running on my iPhone it seems noticeably slower then the rest of the components in my app. I'd appreciate any advice/tips/help anyone could give me. :) Thanks in advance! .h file // // Time_CalculatorViewController.h // Time Calculator // // Created by Adam Soloway on 2/19/10. // Copyright Legacy Pilots 2010. All rights reserved. // #import <UIKit/UIKit.h> @interface Time_CalculatorViewController : UIViewController { //BOOL moveViewUp; //CGFloat scrollAmount; IBOutlet UILabel *hoursLabel; IBOutlet UILabel *minutesLabel; IBOutlet UILabel *hoursDecimalLabel; IBOutlet UILabel *minutesDecimalLabel; IBOutlet UILabel *errorLabel; IBOutlet UITextField *minTextField1; IBOutlet UITextField *minTextField2; IBOutlet UITextField *minTextField3; IBOutlet UITextField *minTextField4; IBOutlet UITextField *minTextField5; IBOutlet UITextField *minTextField6; IBOutlet UITextField *minTextField7; IBOutlet UITextField *minTextField8; IBOutlet UITextField *minTextField9; IBOutlet UITextField *minTextField10; IBOutlet UITextField *hourTextField1; IBOutlet UITextField *hourTextField2; IBOutlet UITextField *hourTextField3; IBOutlet UITextField *hourTextField4; IBOutlet UITextField *hourTextField5; IBOutlet UITextField *hourTextField6; IBOutlet UITextField *hourTextField7; IBOutlet UITextField *hourTextField8; IBOutlet UITextField *hourTextField9; IBOutlet UITextField *hourTextField10; IBOutlet UIButton *resetAll; NSString *minutesString1; NSString *minutesString2; NSString *minutesString3; NSString *minutesString4; NSString *minutesString5; NSString *minutesString6; NSString *minutesString7; NSString *minutesString8; NSString *minutesString9; NSString *minutesString10; NSString *hoursString1; NSString *hoursString2; NSString *hoursString3; NSString *hoursString4; NSString *hoursString5; NSString *hoursString6; NSString *hoursString7; NSString *hoursString8; NSString *hoursString9; NSString *hoursString10; int hourDecimalNumber; int totalTime; int leftOverMinutes; int minuteNumber1; int minuteNumber2; int minuteNumber3; int minuteNumber4; int minuteNumber5; int minuteNumber6; int minuteNumber7; int minuteNumber8; int minuteNumber9; int minuteNumber10; int hourNumber1; int hourNumber2; int hourNumber3; int hourNumber4; int hourNumber5; int hourNumber6; int hourNumber7; int hourNumber8; int hourNumber9; int hourNumber10; } //- (void)scrollTheView:(BOOL)movedUp; - (void)calculateTime; - (IBAction)resetAllValues; @end .m file // // Time_CalculatorViewController.m // Time Calculator // // Created by Adam Soloway on 2/19/10. // Copyright Legacy Pilots 2010. All rights reserved. // #import "Time_CalculatorViewController.h" @implementation Time_CalculatorViewController - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { if( minTextField1.editing || minTextField2.editing || minTextField3.editing || minTextField4.editing || minTextField5.editing || minTextField6.editing || minTextField7.editing || minTextField8.editing || minTextField9.editing || minTextField10.editing || hourTextField1.editing || hourTextField2.editing || hourTextField3.editing || hourTextField4.editing || hourTextField5.editing || hourTextField6.editing || hourTextField7.editing || hourTextField8.editing || hourTextField9.editing || hourTextField10.editing) { [minTextField1 resignFirstResponder]; [minTextField2 resignFirstResponder]; [minTextField3 resignFirstResponder]; [minTextField4 resignFirstResponder]; [minTextField5 resignFirstResponder]; [minTextField6 resignFirstResponder]; [minTextField7 resignFirstResponder]; [minTextField8 resignFirstResponder]; [minTextField9 resignFirstResponder]; [minTextField10 resignFirstResponder]; [hourTextField1 resignFirstResponder]; [hourTextField2 resignFirstResponder]; [hourTextField3 resignFirstResponder]; [hourTextField4 resignFirstResponder]; [hourTextField5 resignFirstResponder]; [hourTextField6 resignFirstResponder]; [hourTextField7 resignFirstResponder]; [hourTextField8 resignFirstResponder]; [hourTextField9 resignFirstResponder]; [hourTextField10 resignFirstResponder]; [self calculateTime]; //if (moveViewUp) [self scrollTheView:NO]; } [super touchesBegan:touches withEvent:event]; } /* // The designated initializer. Override to perform setup that is required before the view is loaded. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { // Custom initialization } return self; } */ /* // Implement loadView to create a view hierarchy programmatically, without using a nib. - (void)loadView { } */ // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; } /* // Override to allow orientations other than the default portrait orientation. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationPortrait); } */ - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } - (void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (void)dealloc { [minutesString1 release]; [minutesString2 release]; [minutesString3 release]; [minutesString4 release]; [minutesString5 release]; [minutesString6 release]; [minutesString7 release]; [minutesString8 release]; [minutesString9 release]; [minutesString10 release]; [hoursString1 release]; [hoursString2 release]; [hoursString3 release]; [hoursString4 release]; [hoursString5 release]; [hoursString6 release]; [hoursString7 release]; [hoursString8 release]; [hoursString9 release]; [hoursString10 release]; [super dealloc]; } -(BOOL)textFieldShouldReturn:(UITextField *)theTextField { //[minTextField10 resignFirstResponder]; //if (moveViewUp) [self scrollTheView:NO]; [self calculateTime]; return YES; } - (IBAction)resetAllValues { minTextField1.text = 0; minTextField2.text = 0; minTextField3.text = 0; minTextField4.text = 0; minTextField5.text = 0; minTextField6.text = 0; minTextField7.text = 0; minTextField8.text = 0; minTextField9.text = 0; minTextField10.text = 0; hourTextField1.text = 0; hourTextField2.text = 0; hourTextField3.text = 0; hourTextField4.text = 0; hourTextField5.text = 0; hourTextField6.text = 0; hourTextField7.text = 0; hourTextField8.text = 0; hourTextField9.text = 0; hourTextField10.text = 0; totalTime = 0; leftOverMinutes = 0; hoursLabel.text = [NSString stringWithFormat:@"0"]; hourDecimalNumber = 0; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; minutesDecimalLabel.text = [NSString stringWithFormat:@"0"]; self.calculateTime; } - (void)calculateTime { minutesString1 = minTextField1.text; minutesString2 = minTextField2.text; minutesString3 = minTextField3.text; minutesString4 = minTextField4.text; minutesString5 = minTextField5.text; minutesString6 = minTextField6.text; minutesString7 = minTextField7.text; minutesString8 = minTextField8.text; minutesString9 = minTextField9.text; minutesString10 = minTextField10.text; hoursString1 = hourTextField1.text; hoursString2 = hourTextField2.text; hoursString3 = hourTextField3.text; hoursString4 = hourTextField4.text; hoursString5 = hourTextField5.text; hoursString6 = hourTextField6.text; hoursString7 = hourTextField7.text; hoursString8 = hourTextField8.text; hoursString9 = hourTextField9.text; hoursString10 = hourTextField10.text; minuteNumber1 = [minutesString1 intValue]; minuteNumber2 = [minutesString2 intValue]; minuteNumber3 = [minutesString3 intValue]; minuteNumber4 = [minutesString4 intValue]; minuteNumber5 = [minutesString5 intValue]; minuteNumber6 = [minutesString6 intValue]; minuteNumber7 = [minutesString7 intValue]; minuteNumber8 = [minutesString8 intValue]; minuteNumber9 = [minutesString9 intValue]; minuteNumber10 = [minutesString10 intValue]; hourNumber1 = ([hoursString1 intValue] * 60); hourNumber2 = ([hoursString2 intValue] * 60); hourNumber3 = ([hoursString3 intValue] * 60); hourNumber4 = ([hoursString4 intValue] * 60); hourNumber5 = ([hoursString5 intValue] * 60); hourNumber6 = ([hoursString6 intValue] * 60); hourNumber7 = ([hoursString7 intValue] * 60); hourNumber8 = ([hoursString8 intValue] * 60); hourNumber9 = ([hoursString9 intValue] * 60); hourNumber10 = ([hoursString10 intValue] * 60); totalTime = (hourNumber1 + hourNumber2 +hourNumber3 +hourNumber4 +hourNumber5 +hourNumber6 +hourNumber7 +hourNumber8 +hourNumber9 +hourNumber10 + minuteNumber1 + minuteNumber2 + minuteNumber3 + minuteNumber4 + minuteNumber5 +minuteNumber6 + minuteNumber7 + minuteNumber8 + minuteNumber9 + minuteNumber10); if (totalTime <= 59) { leftOverMinutes = totalTime; hoursLabel.text = [NSString stringWithFormat:@"0"]; hourDecimalNumber = 0; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >59 && totalTime <= 119){ leftOverMinutes = totalTime - 60; hoursLabel.text = [NSString stringWithFormat:@"1"]; hourDecimalNumber = 1; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >119 && totalTime <= 179){ leftOverMinutes = totalTime - 120; hoursLabel.text = [NSString stringWithFormat:@"2"]; hourDecimalNumber = 2; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >179 && totalTime <= 239){ leftOverMinutes = totalTime - 180; hoursLabel.text = [NSString stringWithFormat:@"3"]; hourDecimalNumber = 3; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >239 && totalTime <= 299){ leftOverMinutes = totalTime - 240; hoursLabel.text = [NSString stringWithFormat:@"4"]; hourDecimalNumber = 4; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >299 && totalTime <= 359){ leftOverMinutes = totalTime - 300; hoursLabel.text = [NSString stringWithFormat:@"5"]; hourDecimalNumber = 5; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >359 && totalTime <= 419){ leftOverMinutes = totalTime - 360; hoursLabel.text = [NSString stringWithFormat:@"6"]; hourDecimalNumber = 6; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >419 && totalTime <= 479){ leftOverMinutes = totalTime - 420; hoursLabel.text = [NSString stringWithFormat:@"7"]; hourDecimalNumber = 7; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >479 && totalTime <= 539){ leftOverMinutes = totalTime - 480; hoursLabel.text = [NSString stringWithFormat:@"8"]; hourDecimalNumber = 8; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >539 && totalTime <= 599){ leftOverMinutes = totalTime - 540; hoursLabel.text = [NSString stringWithFormat:@"9"]; hourDecimalNumber = 9; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >599 && totalTime <= 659){ leftOverMinutes = totalTime - 600; hoursLabel.text = [NSString stringWithFormat:@"10"]; hourDecimalNumber = 10; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >659 && totalTime <= 719){ leftOverMinutes = totalTime - 660; hoursLabel.text = [NSString stringWithFormat:@"11"]; hourDecimalNumber = 11; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >719 && totalTime <= 779){ leftOverMinutes = totalTime - 720; hoursLabel.text = [NSString stringWithFormat:@"12"]; hourDecimalNumber = 12; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >779 && totalTime <= 839){ leftOverMinutes = totalTime - 780; hoursLabel.text = [NSString stringWithFormat:@"13"]; hourDecimalNumber = 13; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >839 && totalTime <= 899){ leftOverMinutes = totalTime - 840; hoursLabel.text = [NSString stringWithFormat:@"14"]; hourDecimalNumber = 14; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >899 && totalTime <= 959){ leftOverMinutes = totalTime - 900; hoursLabel.text = [NSString stringWithFormat:@"15"]; hourDecimalNumber = 15; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >959 && totalTime <= 1019){ leftOverMinutes = totalTime - 960; hoursLabel.text = [NSString stringWithFormat:@"16"]; hourDecimalNumber = 16; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >1019 && totalTime <= 1079){ leftOverMinutes = totalTime - 1020; hoursLabel.text = [NSString stringWithFormat:@"17"]; hourDecimalNumber = 17; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >1079 && totalTime <= 1139){ leftOverMinutes = totalTime - 1080; hoursLabel.text = [NSString stringWithFormat:@"18"]; hourDecimalNumber = 18; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >1139 && totalTime <= 1199){ leftOverMinutes = totalTime - 1140; hoursLabel.text = [NSString stringWithFormat:@"19"]; hourDecimalNumber = 19; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >1199 && totalTime <= 1259){ leftOverMinutes = totalTime - 1200; hoursLabel.text = [NSString stringWithFormat:@"20"]; hourDecimalNumber = 20; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >1259 && totalTime <= 1319){ leftOverMinutes = totalTime - 1260; hoursLabel.text = [NSString stringWithFormat:@"21"]; hourDecimalNumber = 21; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >1319 && totalTime <= 1379){ leftOverMinutes = totalTime - 1320; hoursLabel.text = [NSString stringWithFormat:@"22"]; hourDecimalNumber = 22; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >1379 && totalTime <= 1439){ leftOverMinutes = totalTime - 1380; hoursLabel.text = [NSString stringWithFormat:@"23"]; hourDecimalNumber = 23; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >1439 && totalTime <= 1499){ leftOverMinutes = totalTime - 1440; hoursLabel.text = [NSString stringWithFormat:@"24"]; hourDecimalNumber = 24; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >1499 && totalTime <= 1559){ leftOverMinutes = totalTime - 1500; hoursLabel.text = [NSString stringWithFormat:@"25"]; hourDecimalNumber = 25; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >1559 && totalTime <= 1619){ leftOverMinutes = totalTime - 1560; hoursLabel.text = [NSString stringWithFormat:@"26"]; hourDecimalNumber = 26; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >1619 && totalTime <= 1679){ leftOverMinutes = totalTime - 1620; hoursLabel.text = [NSString stringWithFormat:@"27"]; hourDecimalNumber = 27; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >1679 && totalTime <= 1739){ leftOverMinutes = totalTime - 1680; hoursLabel.text = [NSString stringWithFormat:@"28"]; hourDecimalNumber = 28; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >1739 && totalTime <= 1799){ leftOverMinutes = totalTime - 1740; hoursLabel.text = [NSString stringWithFormat:@"29"]; hourDecimalNumber = 29; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >1799 && totalTime <= 1859){ leftOverMinutes = totalTime - 1800; hoursLabel.text = [NSString stringWithFormat:@"30"]; hourDecimalNumber = 30; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; errorLabel.hidden = TRUE; } else if (totalTime >1859){ hoursLabel.text = [NSString stringWithFormat:@"Error"]; hoursDecimalLabel.text = [NSString stringWithFormat:@"Error"]; errorLabel.hidden = FALSE; } //Minutes Label if (leftOverMinutes < 10) { minutesLabel.text = [NSString stringWithFormat:@"0%d", leftOverMinutes]; } else minutesLabel.text = [NSString stringWithFormat:@"%d", leftOverMinutes]; //Minutes Decimal Label if (leftOverMinutes >=0 && leftOverMinutes <=2) { minutesDecimalLabel.text = [NSString stringWithFormat:@"0"]; } else if (leftOverMinutes >=3 && leftOverMinutes <=8){ minutesDecimalLabel.text = [NSString stringWithFormat:@"1"]; } else if (leftOverMinutes >=9 && leftOverMinutes <=14){ minutesDecimalLabel.text = [NSString stringWithFormat:@"2"]; } else if (leftOverMinutes >=15 && leftOverMinutes <=20){ minutesDecimalLabel.text = [NSString stringWithFormat:@"3"]; } else if (leftOverMinutes >=21 && leftOverMinutes <=26){ minutesDecimalLabel.text = [NSString stringWithFormat:@"4"]; } else if (leftOverMinutes >=27 && leftOverMinutes <=32){ minutesDecimalLabel.text = [NSString stringWithFormat:@"5"]; } else if (leftOverMinutes >=33 && leftOverMinutes <=38){ minutesDecimalLabel.text = [NSString stringWithFormat:@"6"]; } else if (leftOverMinutes >=39 && leftOverMinutes <=44){ minutesDecimalLabel.text = [NSString stringWithFormat:@"7"]; } else if (leftOverMinutes >=45 && leftOverMinutes <=50){ minutesDecimalLabel.text = [NSString stringWithFormat:@"8"]; } else if (leftOverMinutes >=51 && leftOverMinutes <=56){ minutesDecimalLabel.text = [NSString stringWithFormat:@"9"]; } else if (leftOverMinutes >=57 && leftOverMinutes <=60){ minutesDecimalLabel.text = [NSString stringWithFormat:@"0"]; hourDecimalNumber = hourDecimalNumber + 1; hoursDecimalLabel.text = [NSString stringWithFormat:@"%i", hourDecimalNumber]; } } @end

    Read the article

  • Help: Instance Variables & Properties [iPhone]

    - by Devoted
    In something like this: @interface Control_FunViewController : UIViewController { UITextField *nameField; UITextField *numberField; } @property (nonatomic, retain) IBOutlet UITextField *nameField; @property (nonatomic, retain) IBOutlet UITextField *numberField; I understand that "UITextField *nameField;" is an instance variable and "@property ..." is a property. But what do these individual things do? I guess what I'm really asking is how the property is used for example in the implementation file (.m)

    Read the article

  • How to move to next textfield using keyboardtype numberandpunctuation using textfield notification

    - by Rani
    Hi guys, I am having code ItemsController.h UITextField* quantity; UITextField* rate; UITextField* tax2; ItemController.m quantity=[[UITextField alloc]initWithFrame:CGRectMake(158,10.5,140,30)]; quantity.textColor = [UIColor blackColor]; quantity.font = [UIFont systemFontOfSize:15.0]; quantity.backgroundColor = [UIColor clearColor]; quantity.returnKeyType=UIReturnKeyNext; quantity.keyboardType = UIKeyboardTypeNumbersAndPunctuation; quantity.leftViewMode = UITextFieldViewModeAlways; quantity.delegate = self; rate=[[UITextField alloc]initWithFrame:CGRectMake(158,10.5,140,30)]; rate.textColor = [UIColor blackColor]; rate.font = [UIFont systemFontOfSize:15.0]; rate.backgroundColor = [UIColor clearColor]; rate.returnKeyType=UIReturnKeyNext; rate.keyboardType = UIKeyboardTypeNumbersAndPunctuation; rate.leftViewMode = UITextFieldViewModeAlways; rate.delegate = self; tax2=[[UITextField alloc]initWithFrame:CGRectMake(158,10.5,140,30)]; tax2.textColor = [UIColor blackColor]; tax2.font = [UIFont systemFontOfSize:15.0]; tax2.backgroundColor = [UIColor clearColor]; tax2.returnKeyType=UIReturnKeyDone; tax2.keyboardType = UIKeyboardTypeAlphabet; tax2.leftViewMode = UITextFieldViewModeAlways; tax2.delegate = self; - (BOOL)textFieldShouldReturn:(UITextField*)textField { if(textField==quantity) { [rate becomeFirstResponder]; } if(textField == rate) { [tax2 becomeFirstResponder]; } else if(textField==tax2) { [textField resignFirstResponder]; } return YES; } Using UITextfield notifications while I am moving from quantity textfield to rate textfield the keyboard type is alphabetical its getting actually I gav eit has Number and punctuation why I am not getting. can any one help me to solve this as soon as possible. Thanks in advance.

    Read the article

  • 3.1.3 and 3.2 different behaviour

    - by teo
    I'm using a custom cell in tableView with a UITextField - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; UITextField *txtField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 280, 24)]; txtField.placeholder = @"<Enter Text>"; txtField.textAlignment = UITextAlignmentLeft; txtField.clearButtonMode = UITextFieldViewModeAlways; txtField.autocapitalizationType = UITextAutocapitalizationTypeNone; txtField.autocorrectionType = UITextAutocorrectionTypeNo; [cell.contentView addSubview:txtField]; [txtField release]; } } This works fine and the UITextField covers the cell. When i run this with 3.2 sdk or on the iPad the UITextField isn't aligned properly to the left, overlapping the cell and i have to use a UITextField width of 270 instead of 280 UITextField *txtField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 270, 24)]; It seems something is wrong the pixel ratio. How can this be fixed? Is there a way to determine the version of os the device has ( 3.1.2, 3.1.3, 3.2 or maybe even the 4.0) or can it be done another way? Thank you Teo

    Read the article

  • Getting the Value of a UITextField as keystrokes are entered?

    - by Nocturne
    Let's say I have the following code: IBOutlet UITextField* nameTextField; IBOutlet UILabel* greetingLabel; I'd like the greetingLabel to read "Hello [nameTextField]" as soon as the user presses any key. What I need basically is the iPhone equivalent of the Cocoa delegate method -controlTextDidChange: The -textField:shouldChangeCharactersInRange: delegate method is called each time a keystroke occurs: - (BOOL) textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string The string argument returns the character that is pressed. The actual textField's value (nameTextField.text) remains blank however. What am I missing here? (I'd like nameTextField to reflect the exact string that the user has entered so far)

    Read the article

  • First and last UITableViewCell keep changing while scrolling.

    - by W Dyson
    I have a tableView with cells containing one UITextField as a subview for each cell. My problem is that when I scroll down, the text in the first cell is duplicated in the last cell. I can't for the life if me figure out why. I have tried loading the cells from different nibs, having the textFields as ivars. The UITextFields don't seem to be the problem, I'm thinking it has something to do with the tableView reusing the cells. The textFields all have a data source that keeps track of the text within the textField and the text is reset each time the cell is shown. Any ideas? UPDATE: Thanks guys, here's a sample: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"Section %i, Row %i", indexPath.section, indexPath.row); static NSString *JournalCellIdentifier = @"JournalCellIdentifier"; UITableViewCell *cell = (UITableViewCell *)[self.tableView dequeueReusableCellWithIdentifier:JournalCellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:JournalCellIdentifier] autorelease]; cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.accessoryType = UITableViewCellAccessoryNone; } if (indexPath.section == 0) { UITextField *textField = (UITextField *)[self.authorCell viewWithTag:1]; [cell addSubview:textField]; self.authorTextField = textField; self.authorTextField.text = [self.textFieldDictionary objectForKey:@"author"]; NSLog(@"Reading Author:%@", [self.textFieldDictionary objectForKey:@"author"]); } else if (indexPath.section == 1) { UITextField *textField = (UITextField *)[self.yearCell viewWithTag:1]; [cell addSubview:textField]; self.yearTextField = textField; self.yearTextField.text = [self.textFieldDictionary objectForKey:@"year"]; NSLog(@"Reading Year:%@", [self.textFieldDictionary objectForKey:@"year"]); } else if (indexPath.section == 2) { UITextField *textField = (UITextField *)[self.volumeCell viewWithTag:1]; [cell addSubview:textField]; self.volumeTextField = textField; self.volumeTextField.text = [self.textFieldDictionary objectForKey:@"volume"]; NSLog(@"Reading Volume:%@", [self.textFieldDictionary objectForKey:@"volume"]); } return cell; }

    Read the article

  • Disable the Go button in the Keyboard for a UITextfield in iphone app.

    - by coder net
    Hi, My app has a screen where keyboard is always visible. The main element of the screen is a UITextfield. For easy data entering, keyboard is always made visible. When the user finishes entering data and hits Go, the app performs a 4,5 seconds action which is done in the background thread in order to show UIActivityIndicatorView. My problem is that the Go button on the keyboard still shows as enabled since the logic is performed in the background. The user could potentially hit the Go again causing it to run again. I am not able to set editable/userinteraction properties to No because then the keyboard disappears. Is there anyway just to disable the Go button or freeze the keyboard until the background thread returns?

    Read the article

  • Xcode is not calling asp.net webservice

    - by vaibhav
    I have oracle database and using webservice i want to insert some records in to it So i created webservice in asp.net as follows public bool PickPill(string Me_id, string Mem_device_id, string Test_datetime, string Creation_id, string PillBayNo) { string Hed_seq_id = Hed_seq_Id(); bool ResultHED = InsHealthEData(Hed_seq_id, Mem_device_id, Me_id, Test_datetime, Creation_id); bool ResultHET = InsHealthETest(Hed_seq_id, PillBayNo, Test_datetime, Creation_id); if (ResultHED == ResultHET == true) return true; else return false; } this function did all data insertion trick for me i tested this service on the local mechine with ip address http:72.44.151.178/PickPillService.asmx then, I see an example on how to attach asp.net web service to iphone apps http://www.devx.com/wireless/Article/43209/0/page/4 then i created simillar code in xcode which has 2 files ConsumePillServiceViewController.m ConsumePillServiceViewController.h file Now, Using Designer of xcode i created 5 textboxes(Me_id,Mem_device_id,Test_datetime,Creation_id,PillBayNo) with all parameters hardcode as our service demands then modify my ConsumePillServiceViewController.h file as follows @interface ConsumePillServiceViewController : UIViewController { //---outlets--- IBOutlet UITextField *Me_id; IBOutlet UITextField *Mem_device_id; IBOutlet UITextField *Test_datetime; IBOutlet UITextField *Creation_id; IBOutlet UITextField *PillBayNo; //---web service access--- NSMutableData *webData; NSMutableString *soapResults; NSURLConnection *conn; } @property (nonatomic, retain) UITextField *Me_id; @property (nonatomic, retain) UITextField *Mem_device_id; @property (nonatomic, retain) UITextField *Test_datetime; @property (nonatomic, retain) UITextField *Creation_id; @property (nonatomic, retain) UITextField *PillBayNo; - (IBAction)buttonClicked:(id)sender; @end and ConsumePillServiceViewController.m as follows import "ConsumePillServiceViewController.h" @implementation ConsumePillServiceViewController @synthesize Me_id; @synthesize Mem_device_id; @synthesize Test_datetime; @synthesize Creation_id; @synthesize PillBayNo; (IBAction)buttonClicked:(id)sender { NSString *soapMsg = @"" "" "" ""; NSString *smMe_id= [soapMsg stringByAppendingString: [NSString stringWithFormat: @"%@",Me_id.text]]; NSString *smMem_device_id= [smMe_id stringByAppendingString: [NSString stringWithFormat: @"%@",Mem_device_id.text]]; NSString *smTest_datetime= [smMem_device_id stringByAppendingString: [NSString stringWithFormat: @"%@",Test_datetime.text]]; NSString *smCreation_id= [smTest_datetime stringByAppendingString: [NSString stringWithFormat: @"%@",Creation_id.text]]; NSString *smPillBayNo= [smCreation_id stringByAppendingString: [NSString stringWithFormat: @"%@",PillBayNo.text]]; NSString *smRestMsg= [smPillBayNo stringByAppendingString: @"" "" ""]; soapMsg=smRestMsg; //---print it to the Debugger Console for verification--- NSLog(soapMsg); NSURL *url = [NSURL URLWithString: //create a URL load request object using instances : @"http://72.44.151.178/PickPillService.asmx"];//of the NSMutableURLRequest and NSURL objects NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url]; //opulate the request object with the various headers, such as Content-Type, SOAPAction, and Content-Length. //You also set the HTTP method and HTTP body NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMsg length]]; [req addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [req addValue:@"http://tempuri.org/PickPill" forHTTPHeaderField:@"SOAPAction"]; [req addValue:msgLength forHTTPHeaderField:@"Content-Length"]; //---set the HTTP method and body--- [req setHTTPMethod:@"POST"]; [req setHTTPBody: [soapMsg dataUsingEncoding:NSUTF8StringEncoding]]; conn = [[NSURLConnection alloc] initWithRequest:req delegate:self]; //establish the connection with the web service, if (conn) { //you use the NSURLConnection class together with the request object just created webData = [[NSMutableData data] retain];//webData object use to receive incoming data from the web service } }//End of button clicked event -(void) connection:(NSURLConnection *) connection //Recive response didReceiveResponse:(NSURLResponse *) response { [webData setLength: 0]; } -(void) connection:(NSURLConnection *) connection //Repeative call method and append data to webData didReceiveData:(NSData *) data { [webData appendData:data]; } -(void) connection:(NSURLConnection *) connection//If error occure error should be displayed didFailWithError:(NSError *) error { [webData release]; [connection release]; } -(void) connectionDidFinishLoading:(NSURLConnection *) connection { NSLog(@"DONE. Received Bytes: %d", [webData length]); NSString *theXML = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding]; //---shows the XML--- NSLog(theXML); [connection release]; [webData release]; } (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } (void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } (void)dealloc { [Me_id release]; [Creation_id release]; [Mem_device_id release]; [Test_datetime release]; [PillBayNo release]; [soapResults release]; [super dealloc]; } @end I did all things as shown in the website and when i built application it successfully built but in the debuggin window i see (gdb) continue 2010-03-17 09:09:54.595 ConsumePillService[6546:20b] A00000004303101103/13/2010 07:34:38Hboxdata2 (gdb) continue (gdb) continue (gdb) continue 2010-03-17 09:10:05.411 ConsumePillService[6546:20b] DONE. Received Bytes: 476 2010-03-17 09:10:05.412 ConsumePillService[6546:20b] soap:ServerServer was unable to process request. ---> One or more errors occurred during processing of command. ORA-00936: missing expression It should return me true if all things are ok What is this ORA-00936 error all about as it is not releted with webservice Please help me solving this problem Thanks in advance, Vaibhav Deshpande

    Read the article

  • predict location of single-line text from a UITextView

    - by William Jockusch
    Is this possible? Specifically, I have a UITextView, and the text is short enough that it will fit on a single line. I want to predict where it will appear, so that (for example) if I wanted to, I could set up a UILabel that rendered the text in exactly the same location. Once I get that figured out, what I really want to do is pick contentInset and/or contentOffset so that the text of the UITextView and the left-justified UILabel will render in the same location. But I figure the above will let me do that. EDIT: In response to a comment, the fundamental problem I am trying to get around is that UITextField does not let you set the location of the cursor. It appears a lot of people have tried to get around this without success. I need to be able to move the cursor -- inserting/deleting text there is not enough. Control cursor position in UITextField Insert string at cursor position of UITextField Moving the cursor to the beginning of UITextField iOS -- dealing with the inability to set the cursor position in a UITextField

    Read the article

  • How to create Dictionary object in AppDelegate to access objectkey in another ViewController

    - by TechFusion
    Hello, I have created Window Based application and tab bar controller as root controller. My objective is to store Text Field data values in one tab bar VC and will be accessible and editable by other VC and also retrievable when application start. I am looking to use NSDictionary class in AppDelegate so that I can access stroed Data Values with keys. //TestAppDelegate.h @interface { ..... .... NSDictionary *Data; } @property (nonatomic, retain) NSDictionary *Data; //TestAppDelegate.m #import "TestAppDelegate.h" NSString *kNamekey =@"Namekey"; NSString *kUserIDkey =@"UserIDkey"; NSString *kPasswordkey =@"Passwordkey"; @implemetation TestAppDelegate @synthesize Data; -(void)applicationDidFinishLaunching:(UIApplication)application { NSString *NameDefault; NSString *UserIDdefault; NSString *Passworddefault; NSString *testvalue = [[NSUserDefaults standardUserDefaults] stringForKey: kNamekey]; if(testvalue == nil) { NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys: NameDefault, kNamekey, UserIdefault kUserIDkey, Passwordefault kPasswordkey, nil]; self.Data = appDefaults; [[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults]; [[NSUserDefaults standardUserDefaults] synchronize]; } else { } } Here ViewController is ViewController of Navigation Controller which is attached with one tab bar.. I have attached xib file with ViewController //ViewController.h @interface IBOutlet UITextField *Name; IBOutlet UITextField *UserId; IBOutlet UITextField *Password; } @property(retain,nonatomic) IBOutlet UITextField *Name @property(retain,nonatomic) IBOutlet UITextField *UserId; @property(retain,nonatomic) IBOutlet UITextField *Password; -(IBAction)Save:(id)sender; @end Here in ViewController.m I want to store Text Field input data with key which are defined in AppDelegate. I have linked Save Barbutton with action. Here I am not getting how to access NSDictionary class with object and keys in ViewController. //ViewController.m -(IBAction)Save:(id)sender{ TestAppDelegate *appDelegate = (TestAppDelegate*)[[UIApplication sharedApplication] delegate]; //Here how to access knamekey here to set object(Name.test) value with key } Please guide me about this. Thanks,

    Read the article

  • Can I refer to NSDictionary items numerically?

    - by cannyboy
    I'm trying to set up a UITableView which acts as a form. Each cell has within it a UILabel and a UITextField, so one cell is: Name <enter name> ^ ^ UILabel UITextField Now, I'm trying to populate the UILabel and the UITextField from a NSDictionary (from a plist), where it's organized like so: Root Type Value Name String Address String City String etc But in order to get the right labels and textfields in the cellForRowAtIndexPath method, I would have to refer to the Dictionary numerically. Is there any way to do that?

    Read the article

  • I can not hide keyboard by pressing return key

    - by chetan
    I have tried this: In .h file @interface TouchLabelViewController : UIViewController<UITextFieldDelegate> -(IBAction)hideKeyboard:(id)sender; In .m File -(IBAction)hideKeyboard:(id)sender{ [(UITextField*)sender resignFirstResponder]; } And also tried this in .h file -(BOOL) textFieldShouldReturn:(UITextField *)textField; in .m file -(BOOL) textFieldShouldReturn:(UITextField *)textField{ [aTextField resignFirstResponder]; return YES; } But still whenever i touch return key it does not hide keyboard.

    Read the article

  • How to use NSMutableDictionary to store and retrieve data

    - by TechFusion
    I have created Window Based application and tab bar controller as root controller. My objective is to store Text Field data values in one tab bar VC and will be accessible and editable by other VC and also retrievable when application start. I am looking to use NSMutableDictionary class in AppDelegate so that I can access stored Data Values with keys. //TestAppDelegate.h extern NSString *kNamekey ; extern NSString *kUserIDkey ; extern NSString *kPasswordkey ; @interface TestAppDelegate :NSObject{ UIWindow *window; IBOutlet UITabBarController *rootController; NSMutableDictionary *outlineData ; } @property(nonatomic,retain)IBOutlet UIWindow *window; @property(nonatomic,retain)IBOutlet UITabBarController *rootController; @property(nonatomic,retain) NSMutableDictionary *outlineData ; @end //TestAppDelegate.m import "TestAppDelegate.h" NSString *kNamekey =@"Namekey"; NSString *kUserIDkey =@"UserIDkey"; NSString *kPasswordkey =@"Passwordkey"; @implemetation TestAppDelegate @synthesize outlineData ; -(void)applicationDidFinishLaunching:(UIApplication)application { NSMutableDictionary *tempMutableCopy = [[[NSUserDefaults standardUserDefaults] objectForKey:kRestoreLocationKey] mutableCopy]; self.outlineData = tempMutableCopy; [tempMutableCopy release]; if(outlineData == nil){ NSString *NameDefault = NULL; NSString *UserIDdefault= NULL; NSString *Passworddefault= NULL; NSMutableDictionary *appDefaults = [NSMutableDictionary dictionaryWithObjectsAndKeys: NameDefault, kNamekey , UserIDdefault, kUserIDkey , Passworddefault, kPasswordkey , nil]; self.outlineData = appDefaults; [appDefaults release]; } [window addSubview:rootController.view]; [window makeKeyAndVisible]; NSMutableDictionary *savedLocationDict = [NSMutableDictionary dictionaryWithObject:outlineData forKey:kRestoreLocationKey]; [[NSUserDefaults standardUserDefaults] registerDefaults:savedLocationDict]; [[NSUserDefaults standardUserDefaults] synchronize]; } -(void)applicationWillTerminate:(UIApplication *)application { [[NSUserDefaults standardUserDefaults] setObject:outlineData forKey:kRestoreLocationKey]; } @end Here ViewController is ViewController of Navigation Controller which is attached with one tab bar.. I have attached xib file with ViewController //ViewController.h @interface IBOutlet UITextField *Name; IBOutlet UITextField *UserId; IBOutlet UITextField *Password; } @property(retain,nonatomic) IBOutlet UITextField *Name @property(retain,nonatomic) IBOutlet UITextField *UserId; @property(retain,nonatomic) IBOutlet UITextField *Password; -(IBAction)Save:(id)sender; @end Here in ViewController.m, I am storing object values with keys. /ViewController.m -(IBAction)Save:(id)sender{ TestAppDelegate appDelegate = (TestAppDelegate)[[UIApplication sharedApplication] delegate]; [appDelegate.outlineData setObject:Name.text forKey:kNamekey ]; [appDelegate.outlineData setObject:UserId.text forKey:kUserIDkey ]; [appDelegate.outlineData setObject:Password.text forKey:kPasswordkey]; [[NSUserDefaults standardUserDefaults] synchronize]; } I am accessing stored object using following method. -(void)loadData { TabBarAppDelegate *appDelegate = (TabBarAppDelegate *)[[UIApplication sharedApplication] delegate]; Name = [appDelegate.outlineData objectForKey:kNamekey ]; UserId = [appDelegate.outlineData objectForKey:kUserIDkey ]; Password = [appDelegate.outlineData objectForKey:kPasswordkey]; [Name release]; [UserId release]; [Password release]; } I am getting EXEC_BAD_ACCESS in application. Where I am making mistake ? Thanks,

    Read the article

  • I'm trying to pass a string from my first ViewController to my second ViewController but it returns NULL

    - by Dashony
    In my first view controller I have 3 input fields each of them take the user input into and saves it into a string such as: address, username and password as NSUserDefaults. This part works fine. In my second view controller I'm trying to take the 3 strings from first controller (address, username and password) create a html link based on the 3 strings. I've tried many ways to access the 3 strings with no luck, the result I get is NULL. Here is my code: //.h file - first view controller with the 3 input fields CamSetup.h #import <UIKit/UIKit.h> @interface CamSetup : UIViewController <UITextFieldDelegate> { NSString * address; NSString * username; NSString * password; IBOutlet UITextField * addressField; IBOutlet UITextField * usernameField; IBOutlet UITextField * passwordField; } -(IBAction) saveAddress: (id) sender; -(IBAction) saveUsername: (id) sender; -(IBAction) savePassword: (id) sender; @property(nonatomic, retain) UITextField *addressField; @property(nonatomic, retain) UITextField *usernameField; @property(nonatomic, retain) UITextField *passwordField; @property(nonatomic, retain) NSString *address; @property(nonatomic, retain) NSString *username; @property(nonatomic, retain) NSString *password; @end //.m file - first view controller CamSetup.m #import "CamSetup.h" @interface CamSetup () @end @implementation CamSetup @synthesize addressField, usernameField, passwordField, address, username, password; -(IBAction) saveAddress: (id) sender { address = [[NSString alloc] initWithFormat:addressField.text]; [addressField setText:address]; NSUserDefaults *stringDefaultAddress = [NSUserDefaults standardUserDefaults]; [stringDefaultAddress setObject:address forKey:@"stringKey1"]; NSLog(@"String [%@]", address); } -(IBAction) saveUsername: (id) sender { username = [[NSString alloc] initWithFormat:usernameField.text]; [usernameField setText:username]; NSUserDefaults *stringDefaultUsername = [NSUserDefaults standardUserDefaults]; [stringDefaultUsername setObject:username forKey:@"stringKey2"]; NSLog(@"String [%@]", username); } -(IBAction) savePassword: (id) sender { password = [[NSString alloc] initWithFormat:passwordField.text]; [passwordField setText:password]; NSUserDefaults *stringDefaultPassword = [NSUserDefaults standardUserDefaults]; [stringDefaultPassword setObject:password forKey:@"stringKey3"]; NSLog(@"String [%@]", password); } - (void)viewDidLoad { [addressField setText:[[NSUserDefaults standardUserDefaults] objectForKey:@"stringKey1"]]; [usernameField setText:[[NSUserDefaults standardUserDefaults] objectForKey:@"stringKey2"]]; [passwordField setText:[[NSUserDefaults standardUserDefaults] objectForKey:@"stringKey3"]]; [super viewDidLoad]; } @end //.h second view controller LiveView.h #import <UIKit/UIKit.h> #import "CamSetup.h" @interface LiveView : UIViewController { NSString *theAddress; NSString *theUsername; NSString *thePassword; CamSetup *camsetup; //here is an instance of the first class } @property (nonatomic, retain) NSString *theAddress; @property (nonatomic, retain) NSString *theUsername; @property (nonatomic, retain) NSString *thePassword; @end //.m second view LiveView.m file #import "LiveView.h" @interface LiveView () @end @implementation LiveView @synthesize theAddress, theUsername, thePassword; - (void)viewDidLoad { [super viewDidLoad]; theUsername = camsetup.username; //this is probably not right? NSLog(@"String [%@]", theUsername); //resut here is NULL NSLog(@"String [%@]", camsetup.username); //and here NULL as well } @end

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12  | Next Page >