A project I’m working on contains an alert that uses the addTextFieldWithValue:label: private API, this approach has been popular/recommended by a number of developers/blogs, but now that Apple have their automated checking for Private API’s any apps using this technique will be rejected….
“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 following non-public APIs are included in your application:
addTextFieldWithValue:label:
textFieldAtIndex:
Jeff LaMarche has a great article that shows an alternative, that doesn’t use any Private API’s and therefore shouldn’t get you rejected.
The template that creates your .h and .m files within Xcode by default sets the company name to __MyCompanyName__
To correct perform the following…
1) Start up the program Terminal Utilities/Terminal
2) Enter the following where XXXXXXXXXXXXX is what you want to appear in place of __MyCompanyName__:
defaults write com.apple.Xcode PBXCustomTemplateMacroDefinitions ‘{”ORGANISATIONNAME” = “XXXXXXXXXXXXX”;}’
3) Press enter
4) Shut down and restart Xcode.
To have a label recognise line breaks in the text that you enter in the Interface Builder, set the number of lines to 0, and when you want a new line press both the Option key and the Return key
After creating a new version of your data model, and adding the relevant code to handle lightweight migration, to actually get your code to run ensure that you do a clean all targets otherwise you get merge model errors!
Now that I’ve started to do some OpenGL I needed to determine where in my 3D world a user had touched. In order to do this you can use a function called gluUnProject, which isn’t part of the standard framework. I’ve converted the code (so have many others) and posted it here in case it might help someone else.
I used the following article to then use this methods.
If you have a code that is in a vertical section and you would like to select it, for copy/cut/paste/delete functions hold down the alt key while dragging your cursor over the code. The screen shot below shows me selecting //’s so that I can uncomment the code
The selection you make can also be used in pasting and will paste vertical down from your cursor point.
I’ve copied the code below so that I have a reference to it as well.
You also need to ensure the following steps are followed…
Make your controller implement UITextViewDelegate
setup your textfield’s (s) delegate to be your controller
in the controller @interface add an int verticalOffset
in the controller @implementation add the functions below
#pragma mark "-- text editing support --"
// Animate the entire view up or down, to prevent the keyboard from covering the text field.
- (void)moveView:(int)offset {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
// Make changes to the view's frame inside the animation block. They will be animated instead
// of taking place immediately.
CGRect rect = self.view.frame;
rect.origin.y -= offset;
rect.size.height += offset;
self.view.frame = rect;
[UIView commitAnimations];
}
- (BOOL)textFieldShouldReturn:(UITextField *) sender {
[sender resignFirstResponder];
if (verticalOffset!=0) {
[self moveView: -verticalOffset];
verticalOffset = 0;
}
return TRUE;
}
- (void)textFieldDidBeginEditing:(UITextField *)theTextField {
int wantedOffset = theTextField.frame.origin.y-200;
if ( wantedOffset < 0 ) {
wantedOffset = 0;
}
if ( wantedOffset != verticalOffset ) {
[self moveView: wantedOffset - verticalOffset];
verticalOffset = wantedOffset;
}
}