Tuesday, October 21, 2008

iPhone/iPod touch WiFi

Since I'm doing a variety of network programs for iPhones and iPods (FTP OnTheGo, ContactClone) I've got an iPod touch for testing, as well as my iPhone 3G and the older iPhone that's now my wife's. With the network programs, I've been changing settings and noticed a difference in the number of wireless networks they showed.

I did a test sitting at my desk...

The iPhone and iPhone 3G saw 2 wireless networks in the settings, sometimes a third would appear for a few seconds, but would disappear again.

Exactly the same with a first generation iPod touch consistently saw 4 to 5, and a few times as many as 8 wireless networks! The quality was low, so I'd have trouble actually connecting, but was a very surprising difference. I guess the antenna in the iPod is a lot better than the one in the iPhone.

I'm curious how an iPod touch 2nd generation would compare...but not curious enough to buy one yet :)

Monday, October 13, 2008

iPhone Code - Table Header Context Help

Now that the iPhone NDA has been changed, I thought I'd post a bit of code for various things I've done for the iPhone. I wanted to do a contextual help sort of thing for different sections in a grouped table view. This will be in the next version of FTP On The Go and shows some of the features coming if you look closely at the screen :)
Pressing the button pushes a view onto the navigation controller that shows a webpage off our server with the help contents.

I got the graphic for the help button by changing the hue/saturation from an icon purchased from icons-icons.com.
Sorry for bad formatting from the blog stuff.

In the .h file...


In the .m file...

In the viewDidLoad, there's this to set the heights.

tableView.sectionHeaderHeight = SETTING_HEADER_HEIGHT;
tableView.sectionFooterHeight = 6;

- (UIView *)tableView:(UITableView *)tableView
viewForHeaderInSection:(NSInteger)section {
UIView *hdrView = [[UIView alloc]
hdrView.backgroundColor = [UIColor clearColor];
UILabel *label;
label = [[UILabel alloc] initWithFrame:CGRectMake(12, 6, SETTING_HEADER_ROW_WIDTH-100, SETTING_HEADER_HEIGHT)];
label.font = [UIFont boldSystemFontOfSize:SETTING_HEADER_FONT_SIZE];
label.textAlignment = UITextAlignmentLeft;
label.highlightedTextColor = [UIColor whiteColor];
label.textColor = [UIColor darkGrayColor];
label.shadowColor = [UIColor whiteColor];
label.shadowOffset = CGSizeMake(0, 1);
label.backgroundColor = [UIColor clearColor];

if (section==0) {
label.text = @"Downloading Files";
} else if (section==1) {
label.text = @"Sharing \"Saved Files\"";
[hdrView addSubview:label];

UIButton *button = nil;
if (section==1) {
button = [[UIButton alloc] initWithFrame:CGRectMake(SETTING_HEADER_ROW_WIDTH-32, 2, 32, 32)];
[button addTarget:self action:@selector(clickSharingHelp: forControlEvents:UIControlEventTouchUpInside];

if (button!=nil) {
[button setImage:[UIImage imageNamed:@"help32.png"] forState:UIControlStateNormal];
button.showsTouchWhenHighlighted = YES;
[hdrView addSubview:button];
return hdrView;