123rd Day As An iOS Developer

March 3, 2016 - 123rd Day As An iOS Developer

THURSDAY - I learned many freakin' things today and yesterday in my iOS life. Cause you know, my new big project started yesterday, why big? The client is a giant network company. The app is quite easy to make if you inspect the UI, but connecting to the API in a right way is quite complex to me. One of the nicest thing I've done so far to the project that I am talking here was the UI. The UI was designed by my officemate, and it was so pretty.


There's this custom UITextField in the app. So what I did to that was I requested the image (the whitish tranparent background of the textfields) from the graphics artist who designed the wireframe of the app. And then with the power of autolayout - constraints, I programmatically added the UITextFields above those UIImageviews. It took me time though, like 2 to 3 hours.

Next important thing I did to this project was maintaining the codes clean. Oh, I forgot to mentioned that my senior (part time) developer introduced to me a cool 3rd party iOS library for buttons, called: BFPaperButton. I still made a button factory class for buttons though. So yeah, I commend the developer of that BFPaperButton.

Another next thing I learned, it is not nice to layout your buttons manually, even though you're using constraints, to your Navigation Bar. I mean, if you want to put Bar Buttons, assign them as NavigationItems, and not manually laying out them to the Bar.

There are lots, I mean, way too many new things I learned in developing this app, but I'm afraid I got no time to share those to you for now. I'm so busy finishing this app.

FIN.

How To Slide Views With Animation When Keypad Is Present iOS

Ok, so we are here to know how to slide the whole screen (the views: like UITextField) when keypad is present. Have you experienced when your cursor is inside the UITextField and then the Keypad presents but the textfield is now being covered by the keypad? Haha! You are not alone. I've experienced that. So we need to slide up the whole screen to fix the problem.

Check out the codes below:

DISMISSING THE KEYPAD:
- (void)dismissKeyboard
{
    [self.view endEditing:YES];
}

UITextField Delegates (Oh, I forgot to mention that you need to set the delegate of your UITextFields. Set the delegates to self, also put the UITextField Class delegate to your .h file.
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
    [self animateTextField: textField up: YES];
}

- (void)textFieldDidEndEditing:(UITextField *)textField 
{
    [self animateTextField: textField up: NO];
}

Now, for the ANIMATION part:
- (void)animateTextField: (UITextField*) textField up: (BOOL) up
{
    const int movementDistance = 80; // tweak as needed
    const float movementDuration = 0.3f; // tweak as needed
    int movement = (up ? -movementDistance : movementDistance);
    [UIView beginAnimations: @"anim" context: nil];
    [UIView setAnimationBeginsFromCurrentState: YES];
    [UIView setAnimationDuration: movementDuration];
    self.view.frame = CGRectOffset(self.view.frame, 0, movement);
    [UIView commitAnimations];
}


If the tutorial is not clear enough for you, please feel free to shoot me a question or your questions by commenting below of the post or contacting me.

42nd Day As An iOS Developer With No Experience

October 30, 2015 - 42nd Day As An iOS Developer With No Experience BEFORE :)

FRIDAY - One of the things that I have discovered today is the open sourced project made by Chris Miles called "CMPopTipView". Ah I get it now, the CM means the author initials. haha! Anyway, this one is so easy to use. It is all well documented in his repository on Github. Click here.

Ah, I would like to inform you, my dear reader, that not all things that I discover or learn every single day is written here, for instance, I learn my trashy technique on how to layout my views. How do I do it? I don't use autolayout since I just recently learned it. I use center properties of views. Frame and Center. I usually put my views (ex. UIButtons, UITextFields, UILabels, etc...) inside a UIView which I call a container, and then use the power of frames and center. We all know that this can be applied to a project that doesn't need to be rotated.

Also, I posted another question on stackoverflow: http://stackoverflow.com/questions/33418804/input-range-width-of-uitextfield-ios/33428195#33428195

Basically, my question was simple:

Is it possible to set a UITextField's input range (not the number of characters)? You can check out my screenshot below.



At the end, I was the one who answered my own question. I just put two padding to both rightView and leftView of my view (UITextField).


UIView *paddingViewForArrowButton = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 35, 25)];
_billingAddressTextField.rightView = paddingViewForArrowButton;
_billingAddressTextField.rightViewMode = UITextFieldViewModeAlways;

UIView *paddingforBillingLeft = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 25)];
_billingAddressTextField.leftView = paddingforBillingLeft;
_billingAddressTextField.leftViewMode = UITextFieldViewModeAlways;

Finally, the freakin most amazing thing that happened to me today is to finally make my code work. Click the link below and you will be redirected to my another post :)

HOW TO  CORRECTLY FETCH ALL DATA FROM FACEBOOK USING LOGIN VIEW IOS

29th Day As An iOS Developer With No Experience

photo from stephow

October 14, 2015 - 29th Day As An iOS Developer With No Experience

WEDNESDAY - Ah another day as an iOS Developer. A noob iOS Developer who had and has no mentor. I learned yesterday the AFNetworking library. I started working with my colleague, who is our Web Developer/Back End Developer. Basically he is the one who makes APIs for android and iOS apps in our company.

I was happy to learn that in order for your application to connect to the database smoother and faster, you need an API. You connect your app to your API via REST. I was pretty surprise that he doesn't know about REST while he is making a REST. Haha!

Going back to the AFNetworking, I found out that the library (I'm not so sure about this, please correct me by posting your comment below) doesn't accept Error 404. I mean, I really can't remember what was happening in my app when it was receiving an error 404 from the API.

For example, the API throws a reply to my app an error 404 when my app sends to the API a wrong password. That was wrong for me. I told my colleague that he needs to change the error being returned to me, from error 404 to status 200 ok, and just indicate in the data/message that the user inputted a wrong password.

I really enjoy the job!!! Wooo! Except from being pressured all the time, and having no mentor. :(

Lastly, here's the summary of what I have learned for today ( I will try to link here again the tutorials for the following):

Padding of Textfield inputs.
Discovered that 404 status code doesn’t work in AFNetworking.
UILabel Boldify
NSUserDefaults - Remember Me