Jourdein

I code, I experienced, I blog and I share my enthusiasm

RSS
people

Re-Enable Edge toggle on iPhone

any_cellular_data_configuration

Last time, my bill goes up over the roof and into the pond.. :p because the iPhone was intelligent enough to figure out the setting for the Edge APN,Username, etc. I found somewhere on the internet to stop this by entering any incorrect information in it.

However, a couple of days ago, I accidentally accept an update on iPhone carrier setting which removed the configuration page. (the page reside under Settings > General > Network > Cellular Data Network). The removal of the config page allow me to to have an internet connection, which I don’t want because I haven’t subscribe to any package, thus the rate would be insane. (I think, this carrier update is applied to Maxis subscriber only since Maxis has launch its iPhone 3G).

I found a way to revert back to re-appear the config page:

  1. SSH to /User/Library/Carrier Bundle.bundle
  2. Sort list by “latest modified” and selecting it will bring you to another folder.
  3. Find MAXIS_my.bundle and delete it (advised if you backup first in case something happen)
  4. Reboot iPhone

Reference:

No Comments | Tags: , ,

Reset Leopard to its initial state

leopard-welcome

Reset or some called it “revirginize” is putting the Leopard to state where it’s first bought/installed, where you would see welcome screen/video and setup/customize your Mac OS X Leopard installation.

1. Enter “Single User Mode” – (press Command-S during startup)
2. Check file system:

$ /sbin/fsck -fy

3. Mount root partition as writable:

$ /sbin/mount -uw /

4. Remove file .AppleSetupDone (hidden file):

$ rm /var/db/.AppleSetupDone

5. Remove user(s)

$ launchctl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist
$ dscl . -delete /Users/{username}

6. Remove user(s) Home directories:

$ rm -rf /Users/{username}

7. Reboot

I think the option 4 is the key procedure here that make the installation reset to its initial state.

Sources:

No Comments | Tags: , , , ,

Sliding UITextFields visible when keyboard appear

When keyboard visibleBefore keyboard visible



I thought there was an easy way such as enabling it in IB but seem I had to go to Google to find out how. For those who want to know how, here’s the original source.

Mainly, the codes involve on delegate functions:

- (void)textFieldDidBeginEditing:(UITextField *)textField
- (void)textFieldDidEndEditing:(UITextField *)textField

So, here’s the codes

1
2
3
4
5
static const CGFloat KEYBOARD_ANIMATION_DURATION = 0.3;
static const CGFloat MINIMUM_SCROLL_FRACTION = 0.2;
static const CGFloat MAXIMUM_SCROLL_FRACTION = 0.8;
static const CGFloat PORTRAIT_KEYBOARD_HEIGHT = 216;
static const CGFloat LANDSCAPE_KEYBOARD_HEIGHT = 140;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
- (void)textFieldDidBeginEditing:(UITextField *)textField {
   [UIView beginAnimations:nil context:NULL];
   [UIView setAnimationBeginsFromCurrentState:YES];
   // the setAnimationBeginsFromCurrentState allow smooth transition
   // to new text field if the user taps on another
   [UIView setAnimationDuration:0.3];
 
   CGRect textFieldRect = [self.view.window convertRect:textField.bounds
                                               fromView:textField];
   CGRect viewRect = [self.view.window convertRect:self.view.bounds
                                               fromView:self.view];
 
   CGFloat midline = textFieldRect.origin.y + 0.5 * textFieldRect.size.height;
   // find the midline of textfield
   CGFloat numerator = midline - viewRect.origin.y - MINIMUM_SCROLL_FRACTION
                       * viewRect.size.height;
   CGFloat denominator = (MAXIMUM_SCROLL_FRACTION - MINIMUM_SCROLL_FRACTION)
                       * viewRect.size.height;
   CGFloat heightFraction = numerator / denominator;
 
   if (heightFraction < 0.0) { heightFraction = 0.0; }
   else if (heightFraction > 1.0) { heightFraction = 1.0; }
 
   animatedDistance = floor(PORTRAIT_KEYBOARD_HEIGHT*heightFraction);
   self.view.frame = CGRectMake(self.view.frame.origin.x,
   self.view.frame.origin.y-animatedDistance,
   self.view.frame.size.width,
   self.view.frame.size.height);
   [UIView commitAnimations];
}
1
2
3
4
5
6
7
8
9
10
11
12
13
- (void)textFieldDidEndEditing:(UITextField *)textField
{
    CGRect viewFrame = self.view.frame;
    viewFrame.origin.y += animatedDistance;
 
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationBeginsFromCurrentState:YES];
    [UIView setAnimationDuration:KEYBOARD_ANIMATION_DURATION];
 
    [self.view setFrame:viewFrame];
 
    [UIView commitAnimations];
}

However, you could also refer to UICatalog example which also has example quite similar to this one but I prefer this one.

No Comments | Tags: , , , ,

Hide keyboard when a field lost focus

I’ve found 2 ways, currently, on how to hide keyboard when textfield lost focus on when user has done editing.

  • Delegate method
  • Callback for the event nbsp;nbsp;Did End On Exit

Delegate method

1
2
3
4
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
	[textField resignFirstResponder];
	return YES;
}

Very simple indeed. Just add this function in view where you want textfield to be delegated to.

Callback for event Did End On Exit

Outlines:

  • Create dummy method: -(IBAction)endEditing:(id)sender;
  • Connect event codeDid End On Exit/code to the dummy method created

References:

No Comments | Tags: , , , ,

Radio Button to UISegmentedControl

There’s no radio button in XCode for iPhone. Following good design practices, if you have 3 or 4 options, it is good to show it all rather than putting in drop down menu. It it is on web application, you can do it as radio button but if for application in iPhone, there is no radio button. However, there’s UISegmentedControl that function as in radio button.

Radio Button for Web App on iPhone

Radio Button for Web App on iPhone

UISegmentedControl

UISegmentedControl

Now, have to convert all algorithm from javascript to objective-c for iphone app. However, I want to test it, rather on iphone simulator, on real iphone but there’s other restrictions to it… “Code Signing”, “IDP (IPhone Developer Program). I did found the workaround but didn’t try yet.

What you need:

  • Jailbreak iPhone
  • Link-Identity-Editor..
  • Certificate..Code Signing or what-not.
  • etc..etc.

Here’s the link for detailed instructions. Better read there coz I don’t applied it yet. You’ll need to read about Code Signing Identify.

Here is another reference but seemed to not work but I think it just missed steps. The other steps is good for reference.

No Comments | Tags: , , , ,

Array Controller bounded to an Array

I was scratching my head of why the heck does the my tableview does not automatically update its data.

My binding:

NSArrayController = ACIssues
Controller Class = Issue Controller (have NSArray property subviewControllers)

ACIssues has it contentArray binded to subviewControllers’s array in Issue Controller. Somehow, changes made to the array of subviewControllers in Issue Controller does not reflect on other table which I had it binded to ACIssues.

After searching the internet, I found this

http://boredzo.org/blog/archives/2008-11-26/how-to-work-with-a-bound-to-array (open in new window)

Very good one. What it said… There’re right and wrong way to bind.

The right way is by using indexed accessors. Then, your Array Controller will see any changes you’ve made. What I did was creating indexed accessor methods.

- (void)insertObject:(id)object inSubviewControllersAtIndex:(unsigned)index {
[[self subviewControllers] insertObject:object atIndex:index];
}


- (void)removeObjectFromSubviewControllersAtIndex:(unsigned)index {
[[self subviewControllers] removeObjectAtIndex: index];
}

and calling it where I wanted to change the array.

[self insertObject:obj inSubviewControllersAtIndex:(index + 1)];
[self removeObjectFromSubviewControllersAtIndex:index];

the structure of this indexed accessor:

insertObject:(id)object inKeyAtIndex:(unsigned)index

where key is the property or in my case array that is binded to the Array Controller.

No Comments | Tags: , , , , ,

Disable iPhone 2.0 keyboard dictionary autocorrect

Though iPhone dictionary keyboard is an innovative word suggestion but sometimes, I would like the keyboard to be turned off so that I would be able to write in my language. Actually, if it turned off, I would not mind. I think I would be typing faster if the dictionary is disabled.

Thus, I googled on how to disable the dictionary for iPhone 2.0. In iPhone 1.1.4 firmware, they have the tweak called KB that will disabled it. But in 2.0, none of it happened to be anywhere yet. The solution I found required SSH to some folder and renaming it language bundle.

The instruction requires terminal to connect to iPhone through SSH but I prefer using Transmit (FTP app).

So, what you require are:

  • SSHed iPhone
    (I installed OpenSSH from Cydia. This mean that your phone is already jailbroken ‘ed’)
  • FTP App (I use Transmit on MacBook)

Where to start?

  1. Open FTP application. Connect to iPhone using IP address with username:root password:alpine
  2. Point you FTP browser to /System/Library/TextInput/
  3. Rename TextInput_en.bundle to something. I rename to TextInput_en_bak.bundle.
  4. Create a new folder with original name which you have renamed TextInput_en_bak.bundle
  5. Respring or reboot you iPhone to commit changes.

If you would like to see the source of website that I’ve referred to, visit:

http://n00.be/archives/724/

No Comments | Tags: , , ,