Categories
iPhone app

Three way to create customized input control for UITextField

Reading Time: < 1 minute

Last Updated on September 5, 2012 by stlplace

Recently I need to create some customized textfield to input numbers and text on iPad. I don’t like the default keyboard on iPad because it takes too much of the screen, and in some cases covers up the input field.

1) From iphonedevsdk: What is proper way to do UITextField text change call back? (this also mentioned by stackoverflow)

[textField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventTouchDown];

The downside of this approach is: it takes a press (a tap and hold) to trigger the event.

2) InputView
Create a customized view such as this one at raywenderlich, then set the inputView of textfield. I used this approach to create a number pad that used to only input numbers. There is some limit to this approach as well: the location of customized input view is usually fixed, and in my case (a double picker) for text field (table cell), that is not ideal. I was using pop over controller (again raywenderlich), combined with approach 1, the user does not like the “hold”. After I changed to approach 2, the user does not like the fixed location of input view. So I did more research, and eventually I found the following approach that works for me.

One tip: make sure lock the input view, otherwise it will mess up things after iPad rotation.
– (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return NO;
}

3) self delegate, UITextFieldDelegate

Make sure do this in viewDidLoad (or other place initialize the text field):
myTextField.delegate = self;

This way I could have both “single tap” and the pop over controller.

Categories
Fun

I can repair it

Reading Time: < 1 minute

Last Updated on May 9, 2012 by omaha

Our new camry

I was involved into a car accident in the past weekend. We are all fine, so as the other party. The main thing is both cars got some damage. It’s funny when I drove the broken car on the road, I got quite a few “look back” from other drivers. And yesterday, at McDonald parking lot, the lady who looks after the parking lot, said “what happened to your car”. Not to mention, our daughter Serenity volunteered to repair the car.

Last but not least, my wife insisted I declare “Minjie is the one who got involved in the accident” 🙂

Fun aside, we are truly blessed we were not hurt.

Categories
Fun

Some updates for myself and my family

Reading Time: 2 minutes

Last Updated on April 14, 2012 by omaha

Have not done this for a while. I have changed job again, and in the new year started a developer position very close to home, doing mobile (iOS, iPhone, iPad) development. I love what I am doing now, because I got opportunity to create an app from back end (database, web service) to front end (iOS UI, local database). At the same time, I have set up the source code control system (SVN), and web server (MS IIS).

My wife started as purchase assistant job at a local manufacturing company, the main task is communicate with Chinese suppliers, involves both Chinese language and mechanical engineering. As I was ME major, I got opportunity to talk to my wife about some of her tasks. Back to ME.

Baby is still a very important part of our life. She grew quite a bit, in terms of language (both Chinese and English), and other skills. We think the Hope Montessori Toddler program (Creve Coeur) helped quite a bit. It helped her be more confident as a person.

In my spare time, I still pay attention to the stock market, US politics, and last but not least, volunteer (serve) in Church. I have a change of heart on politics: in the past I think the government should take care of at least two things: health care and education. Now I think the family and individual should take more responsibility. Also I felt some of the welfare program is not necessarily good for the recipients in the long term. As I read from the news one welfare recipient (woman) is alleged helping her husband kill another person (lady) in Maine. On the tax, it seems local tax is always rising as time goes, and the federal deficit cannot sustain if we don’t raise the overall rate for all the tax payers. The buffett rule (have the rich pay a little more) is just a cup of water on the fire.

Last but not least, we bought a new car (Camry, our first), I like the blue booth audio very much, besides its signature smoothness.

More later…

Categories
iPhone app

Create .NET WCF Restful web service for iOS

Reading Time: < 1 minute

Last Updated on March 15, 2012 by stlplace

I need to create a .NET web service consumable by iOS device. Did some research and found out WCF Restful service is the way to go. I used the following examples (tutorials) to construct my web service.

0) Basic Resource Service (link here).
This is basically a self hosting web service run in a main program. A good starting point to learn dataContract, webHttp, etc.

1) I need to change from a console app to a web service, and host on IIS, for this refer to
project 1
and
2(Space Service, a WCF web service app)

2) I need to combine 2 services into one program, and I referred to endPoint.tv plural sight podcast “Building RESTfil services with WCF”

The video above mentioned the httputil.js, HTTP POST/PUT utility, which is handy to test “POST” method. Another tool I used to test GET/POST, is “fiddler”.

A Guide to Designing and Building RESTful Web Services with WCF 3.5, also by Aaron Skonnard, Pluralsight

Essentially here we need to design a scheme (end points) for hosting multiple services.

3) Database connection, I used sql client, which is pretty vanilla.

4) Use pretty path instead of port number (routing service, refer to SimpleREST service again)

Also “code project” example
http://www.codeproject.com/Articles/105273/Create-RESTful-WCF-Service-API-Step-By-Step-Guide