At the moment I’m working with Core Graphics and drawing UIViews by hand a lot. Therefore there is a big necessity to calculate many coordinates for drawing shapes and more stuff. While browsing CGGeomitry.h I came across a few nice functions providing calculations for some important “Points of Interest” within an CGRect. CGrectGetMinX, CGRectGetMinY, CGRectGetMaxX, CGRectGetMaxY, CGRectGetMidX and CGRectGetMixY help finding important edge points of a CGRect without calculating them by hand. I’ve quickly drawn a little cheat sheet for these points, maybe it’s as helpful for you as it is for me. (big PNG or PDF).

Dr. Touch wrote also an useful article about CGRect Tricks making every objective-c developers life easier!
Last month I switched my phone provider and because my iPhone 3GS was already updated to iOS4 I can’t unlock it at the moment. So this seems to be the best chance to give Android a try. Georg thankfully provided me his unused Motorola Milestone (aka Motorola Droid) and I’m using it since last week as my primary phone.
Beeing spoiled by the iPhone it’s a bit strange to get into using Android. Things are on different places, they have different names and the look and feel takes some to get used to it. It actually feels a bit like the moment switching from Windows to Mac OS, with the difference of being more skeptical towards Googles mobile operating system.
Using Googles system for some weeks will help me to forge an opinion and on the decision to get deeper into Android for my business. Beforehand I can tell you what’s great so far: The notification system is brilliant and these widgets are just wonderful - the iOS platform could definitively learn something by watching these ideas.
Many other things, positive and negative, could be mentioned but I’d like to use the phone for some more weeks to get a more sophisticated opinion and insight. Maybe Froyo will land soon for the Milestone as promised and I could test the latest creation of Android. Stay tuned!
pictures by gillyberlin (cc)
I’m updating my app Lisconizer at the moment and had the need for some useful code I’d like to share with you. The use case is quite common and simple. I use an UIScrollView with paging, in fact there are two pages filling the whole screen. You can swipe to the right side to get a second part of the UI. When this part of the UI gets visible the app should fetch some data from the Twitter API - on the other hand, if it’s not visible anymore it should stop fetching data.
I needed to know two things to get this work as described.
- When did the UIScrollView finish scrolling?
- Which page is visible after scrolling?
The first point is easy to figure out by using the the UIScrollViews delegate methods. Just add the -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView method to your viewcontroller. This method will trigger after the scrolling is done including all animations and decelerating.
For the second part we need to calculate the visible rectangle on the scroll view. The UIScrollView class provides all information for the calculation of this CGRect and I packed it into a helper class.
+ (CGRect)scrollViewVisibleRect:(UIScrollView*)scrollView {}
CGRect visible;
visible.origin = scrollView.contentOffset;
visible.size = scrollView.bounds.size;
float scale = 1.0 / scrollView.zoomScale;
visible.origin.x *= scale;
visible.origin.y *= scale;
visible.size.width *= scale;
visible.size.height *= scale;
return visible;
In my case (two pages which are full screen sized) I can use the following delegate method to determine if the visible page is the first or the second page.
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
if([Helper scrollViewVisibleRect:scrollView].origin.x != 0) { [_comPicViewController loadData];
}
else {
[_comPicViewController stopLoadingData];
}
}
A little math would also allow to calculate a generic number of pages with generic size by setting the number of pages in relation to the origin of the visible rectangle.
Dank der AGB-Änderungen von T-Mobile konnte ich meinen extrem überteuerten Vertrag (was tut man nicht alles für ein iPhone) kündigen. Die beste Alternative in Österreich bis 30. Juni 2010 ist Big Bob von der Telekom. 1000 Minuten und 1000 SMS um € 8,80 im Monat und auch noch ohne Vertragsbindung. Für günstige € 4,- im Monat bekommt man 1 GB Datentransfer mit aufs Handy, perfekt für jedes Smartphone.
Nachdem ich auf Twitter schon einigen Leuten Tips zur Anmeldung von Bob gegeben habe will ich hier nochmal alles zusammenfassen damit auch jeder rechtzeitig seinen neuen Tarif noch bekommt. Big Bob gibt es noch bis 30. Juni 2010 und wer sein Starterpaket am 29.6. kauft ist trotzdem zu spät dran. Der Anmeldeprozess bei Bob ist etwas verstrickt und dabei kommt es zu Verzögerungen. Hier die notwendigen Schritte:
- Freigeschaltenes Handy organisieren
- Bob Starterpaket (online) kaufen
- Die Simkarte aktivieren
- einen Tag warten im Moment (lt. Hotline wegen technischer Probleme)
- Big Bob (online) anmelden
- Auf eine Testbuchung von € 0,10 auf dem Konto warten (darauf warte ich im Moment)
- Den Aktivierungscode aus dem Buchungstext der Testbuchung entnehmen und erst dann kann man Big Bob endgültig (online) aktivieren.
Erst ab dem Zeitpunkt der Aktivierung mit dem Code ist die Anmeldung vollständig. Dies muss bis 30. Juni passieren damit das Big Bob Paket noch in Anspruch genommen werden kann. Das Datenpaket kann dabei jederzeit nachgeholt werden, wer also, so wie ich, erst ab 23.7. vollen Bedarf hat kann sich derweil die € 4,- sparen. Verrechnet wird übrigens auch erst ab dem Zeitpunkt der Aktivierung mit dem Code.
Das Timing ist also nicht so unwichtig.
Ich bin in keiner Weiße mit der Telekom in Verbindung weil ich hier Bob empfehle. Auch Drei hat ähnlich günstige Tarife ohne Vertragsbindung. Drei will ich pers. aber nicht verwenden da es dort keinen Support für EDGE gibt.
… das ist auch der längste Text den ich bisher am iPad geschrieben habe, ging erstaunlich gut muss ich sagen.
Saw this here a while ago and laughed out loud, it’s so true. I’ll try to measure code quality by wtf per minute for future projects ;-)
I’ve planned to play around with OpenSteer for my master thesis today and didn’t get my XCode 3.2.2 compiling the project included with the package downloaded from Sourceforge. After several hours of trying around and researching on the web I found the solution, as usual it’s so close and I didn’t see it. Just use the source code form the SVN repository and everything works fine. Fire up your terminal and execute the following command to get the latest version of this project.
svn co https://opensteer.svn.sourceforge.net/svnroot/opensteer/trunk opensteer
- happy open steering


