Blog

Once again, I am incapable of keeping this information in my head so I will write it here.

To hide the row seprators

self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

To change the colour of them

self.tableView.separatorColor = [UIColor redColor];

Continue reading

Three20 and xCode 3.2.3

Posted on 22, Jun

After the updated of last night I opened up the shiny new xcode 3.2.3 and tried to build TT. I got the following errors

“___save_vfp_d8_d15_regs”, referenced from:
…..
“___restore_vfp_d8_d15_regs”, referenced from:

Turns out this is to do with the new settings that are used for targeting certain OSs. The answer was on this page.

“You are building against ARM7 and it’s not allowed when targeting iOS4 and base sdk is os3.

Go to your project settings and make sure “Build Active Architecture Only” is selected. Then on active Architecture choose Arm 6 and it
will all be fine”

I did, and it was. Nice to have what looks like a scary problem fixed so easily. Google rocks.

Stu

Continue reading

This is only going to be of use to the people already traveling down the road of Three20. We are am using TTPostControllerDelegate’s in a lot of our table views to allow us to load data from remote Web Services. Today I was wondering if there was a way for my ViewController to know that the data for its table had arrived. Turns out, there is.

Firstly you need to implement TTModelDelegate.

Secondly you add

- (void)modelDidFinishLoad:(id<TTModel>)model {
        [super modelDidFinishLoad:model];
        
        // Do magic here
        ….        
}

into your ViewController.

In case you are wondering there is also a modelDidStartLoad.

Stuart

Continue reading

Detecting device type

Posted on 7, Jun

I can’t remember if I talked about this before but there has been an update to Eric Sadun’s Category to help detect device types between iPhone, iPod Touch etc.

You can grab the code here.

Continue reading

To Three20 or not to Three20

Posted on 4, Jun

As you maybe have guessed this post is about the Three20 framework which has been developed for iPhone development. At this point it is only fair recognise Chris McClelland from Ecliptic Labs as being the person that introduced me to it. At the time of my first introduction I hated it with a passion, I felt that it restricted you too much and didn’t give enough benefits. Due to an extremely tight project schedule and against my better judgement we decided to use TT for the City Of Culture application that we wrote for the Londonderry~Derry bid to be the City Of Culture 2013. During the development things finally clicked into place. I suppose I should have known better than to doubt Chris.

Even the creators of TT admit that there are some situations that it really doesn’t suit but if you have a project that required information to be gathered from remote sources then it deserves a long hard look. There are loads of examples that come along with the source for TT but the example which downloads posts from Twitter is an excellent place to start.

I have also found it to be an excellent way to layout simple pages like about screens etc. Below is an example of one that I created for the City Of Culture.

@implementation TellAStoryIntroViewController

- (void)dealloc {
[super dealloc];
}

- (id)init {
        if (self = [super init]) {
                
                self.tableViewStyle = UITableViewStyleGrouped;
                
                TTImageView *backgroundImage = [[TTImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 420)];
                [backgroundImage setUrlPath:@"bundle://background2.png"];
                
                [self.view insertSubview:backgroundImage atIndex:0];
                [backgroundImage release];
                
                self.tableView.backgroundColor = [UIColor clearColor];
                self.title = @”Tell A New Story”;
                self.variableHeightRows = YES;

                
                UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 280, 280)];
                
                UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 280, 230)];
                label.text = @”In the 1920s, Ernest Hemingway bet ten dollars that he could write a complete story in just six words. He wrote:\n\n\”For Sale: baby shoes, never worn.\”\n\nHe won the bet and a legenderry story was born…tell us your cultural story in six words.”;
                label.font = [UIFont systemFontOfSize:16];
                label.backgroundColor = [UIColor clearColor];
                label.textColor = [UIColor darkGrayColor];
                label.left = 20;
                
                label.numberOfLines = 20;
                [view addSubview:label];
                
                
                self.tableView.tableHeaderView = view;
                [label release];
                
                self.dataSource = [TTSectionedDataSource dataSourceWithObjects:
                                                 @"",
                                                 [TTTableTextItem itemWithText:@"Tell Your Story"
                                                                                                         URL:@"tt://tellAStory"
                                                                                        accessoryURL:nil],
                                                 [TTTableTextItem itemWithText:@"More information"
                                                                                                         URL:kTellAStoryInstructionLink
                                                                                        accessoryURL:nil],
                                                 nil];
                
                
        }
        
        return self;
}

@end

All of this code gives you a screen like this.

PastedImage1Copy-2010-06-4-21-20.tiff

And I really do mean that, what I put in above is all the code within the ViewController. All you have to do is inherit from TTTableViewController. If I get some time over the next few weeks I will post some more example of our implementations using TT.

As for the answer to the question in the title, as long as you have weighed up the pros and cons, yes, do Three20.

Stu

Continue reading

Facebook Graph API on iPhone

Posted on 26, May

After fighting with the Graph API for a few weeks we seem to have finally tamed the beast. We are using the old Facebook Connect API to log into Facebook and then calls to the new Graph API to get the data.

The idea of using the old system for log-in came from http://github.com/ryanscott/bamboo/. The reason we used it was that just using Graph for logging in had problems with the sessions expiring after 1 hour and making the user log in again. There is probably a better way around the issue but we needed something quickly.

Stu

Continue reading

iPhone Cookies and Facebook

Posted on 13, May

In an app that we are currently working on we are using a UIWebView to log the user into Facebook. We have had a host of problems with the FB integration which I will go into another time but one problem we had was that login details where being cached within the application. This meant that whoever was the first person to log into the application stayed logged in whether they liked it or not. Even trying to open another UIWebView to the FB logout page didn’t work. What did work however was to delete the cookies that FB had stored with the Application directory.

Here is the code to do it.

        NSHTTPCookieStorage *jar = [NSHTTPCookieStorage sharedHTTPCookieStorage];
        
        NSArray *cookies = [jar cookies];
        
        for (id cookie in cookies) {
                [jar deleteCookie:cookie];
        }

It might seem like overkill to delete all the cookies rather than just the ones related to Facebook but I couldn’t get it to work for just the FB domain, I had to delete them all.

Stu

Continue reading

MockApp

Posted on 20, Apr

Before I go any further, I have a confession to make. Gary (@garygall155) sent me a link about it ages ago and I completely ignored it. My only defence is that Gary sends me about 10 emails each day with things I should look at. If I did look at all of them I would get nothing else done.

Due to the fact that I ignored the email I am extremely late to the party but this morning I finally downloaded the MockApp template for PowerPoint and so far I am really impressed. We are constantly looking for ways to improve our design and development processes and I think that this will fill a gap for us.

MockApp is simply a collection of PowerPoint (or Keynote) presentations that allow you to cut and paste from a library of iPhone UI elements to create a mocked up app UI. The mocked up UI can then be presented to a client either as a series of screens or you can link the UI elements to specific pages in your presentation so that they get a feel for the navigation through the app. Clients find it hard to visualise apps based on wireframe or sketches so this should help us confirm that we have in mind for an app is similar to what the client expects to see. Most importantly it gets something in front of a client quickly so if we are wrong about their requirements we find out. As the old saying goes, Fail Fast, Fail Early, Fail Cheap.

Hopefully we will have a few opportunities to use this in the near future so I keep you posted on how it is working out.

Stu

Continue reading

One other UIWebView thing

Posted on 13, Apr

I wanted to load in a local html page so I just used this.

        [self.aboutWebView loadRequest:
         [NSURLRequest requestWithURL:
         [NSURL fileURLWithPath:
         [[NSBundle mainBundle] pathForResource:@”AboutUs” ofType:@”html”]isDirectory:NO]]];

Continue reading

Back again

Posted on 13, Apr

Sorry it has been so long since I last posted anything. It is no excuse but I couldn’t get any blogging software that I liked on the Mac and I couldn’t face starting a Virtual Machine just so I could use LiveWriter.

Anyway, I have MacJournal that I got in the last MacHeist so hopefully it will OK.

So this is a short one about UIWebViews. I was using a WebView to format an About screen for a client. It worked pretty well but I got hit with two small issues.

Issue #1 – Scrolling

The first one was how to stop the user scrolling the view. The answer to that was some sneaky javascript.

<script>
        document.ontouchmove = function(event) {
                if (document.body.scrollHeight == document.body.clientHeight)
                        event.preventDefault();
                }
</script>

Issue #2 – External links

The second was making a link open in the safari app rather than within the WebView. This involved making the containing View us the UIWebViewDelegate and implementing this.

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {

        if (navigationType == UIWebViewNavigationTypeLinkClicked) {
                [[UIApplication sharedApplication] openURL:request.URL];
                return false;
        }
        return true;
}

That is it for now.

Stu

Continue reading