App development

UIViewController offsets scrollview subviews

I was just wondering why my Scrollview Content would always beoffset to what i set it up in Storyboard (Xcode). I use a UIViewController and changed it’s view’s class to UIScrollView.

The layout of my scrollview in Xcode Storyboard
The layout of my scrollview in Xcode Storyboard

The problem was, that all the content which i played out in Xcode was offset by the height of the toolbar during runtime. This did not happen when the view was of class UIView, as by default. I therefore tried to set the subviews frames during runtime but this seems to be restricted by the loaded nibs somehow.

Subviews have a offset in y direction with a height of the toolbar
Subviews have a offset in y direction with a height of the toolbar

for(UIView* subview in self.view.subviews){ [subview setFrame:CGRectOffset(subview.frame, 0, -[self navigationController].toolbar.frame.size.height)];}

I finally found the reason for my problem in the attributes inspector of my ViewController.

Turn "Adjust Scrollview Insets off"
Turn “Adjust Scrollview Insets off”

The Option “Adjust Scroll View Insets” must be disabled for this purpose. It’s probably something which tries to prevent the offset from being hidden by the toolbar. But using the layout in interface builder to manage your subviews obviously interferes with this option. You should therefore turn it off!

offset removed by turning off "Adjust Scrollview Insets"
offset removed by turning off “Adjust Scrollview Insets”

Cheers,

Jan

Advertisements
App development

Menulet for iTunes volume

Menulet to control iTunes volume

Just needed a quick access to control uatunes volume since this also applies to the airplay volume. Here’s a small Menulet which offers a slider to control it. Have fun 😉

Download/a>

I used the ScriptingBridge and this article to build the app!

App development

Solution: UIScrollview that doesn’t interfere with content touches

Hi there, i’m currently working on a drawing-application which uses a scrollview to navigate threw the content. With the normal UIScrollview you will definitely run into problems!

The problem is that UIScrollView will only deliver taps but no movement gestures to it’s content.

1) So i was looking for a solution to pan and zoom with 2 fingers and interact with the content-view with one finger.

2) Also it should be possible to have a period of time in which the 1 finger touch event can be canceled by the two finger events. This is useful since people tend to start with one finger followed by the second one a little later.

3)Also it should be possible to touch the screen with a second finger without canceling the content interaction!

The idea was to filter all the touch-events, but since UIScrollView uses gesture recognizers (namely UIScrollViewPanGestureRecognizer which inherits from UIPanGestureRecognizer) you can’t filter these touches since there aren’t any but the first touchesBegan…

To solve these problems i did the following:

  1. Set setCanCancelContentTouches:NO when you detect a 1 touch event in touchesBegan: works but you still have the problem with 2).
    • Solution: Use a timer to set setCanCancelContentTouches:NO after a period like 0.1 seconds or so
      • Problem: In the first moments the gesture recognizer will interfere with your touch movements and use them instead
        • Solution: Reconfigure all pangesture recognizers to only accept 2 touch events
Note that i check the gesture recognizers against isKindOfClass not isMemberOfClass since UIScrollViewPanGestureRecognizer inherits from UIPanGestureRecognizer.
Also dont worry about touchFilter! This is the contentview, which in fact doesn’t filter the touches but uses the prefiltered ones!
When the user starts with a one finger gesture and (before timer fired) continues with a second one, beganTouches: and canceledTouches: will be called in this order. The number of touches in canceledTouches will therefore be 2; your contentview must be aware of this, cause if it ignores two touch events it won’t get the canceled event which could result in quite strange behavior.
  1. #import “JWTwoFingerScrollView.h”
  2. @implementation JWTwoFingerScrollView
  3. #pragma mark –
  4. #pragma mark Event Passing
  5. (id)initWithCoder:(NSCoder *)coder {
  6. self = [super initWithCoder:coder];
  7. if (self) {
  8. for (UIGestureRecognizer* r in self.gestureRecognizers) {
  9. NSLog(@“%@”,[r class]);
  10. if ([r isKindOfClass:[UIPanGestureRecognizer class]]) {
  11. [((UIPanGestureRecognizer*)r) setMaximumNumberOfTouches:2];
  12. [((UIPanGestureRecognizer*)r) setMinimumNumberOfTouches:2];
  13. }
  14. }
  15. }
  16. return self;
  17. }
  18. (void)firstTouchTimerFired:(NSTimer*)timer {
  19. [self setCanCancelContentTouches:NO];
  20. }
  21. (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
  22. [self setCanCancelContentTouches:YES];
  23. if ([event allTouches].count == 1){
  24. touchesBeganTimer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(firstTouchTimerFired:) userInfo:nil repeats:NO];
  25. [touchesBeganTimer retain];
  26. [touchFilter touchesBegan:touches withEvent:event];
  27. }
  28. }
  29. (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
  30. [touchFilter touchesMoved:touches withEvent:event];
  31. }
  32. (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
  33. NSLog(@“ended %i”,[event allTouches].count);
  34. [touchFilter touchesEnded:touches withEvent:event];
  35. }
  36. (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
  37. NSLog(@“canceled %i”,[event allTouches].count);
  38. [touchFilter touchesCancelled:touches withEvent:event];
  39. }

It really took me ages to get this running, there were plenty other solutions which all didnt meet my needs. Some used a timer but delayed the first touch event, others allowed only one touch event but interrupted as soon as there was a two finger touch event. Some threads on stackoverflow might be interesting for you, since it also helped me to get this solution working!

http://stackoverflow.com/questions/787212/scrolling-with-two-fingers-with-a-uiscrollview

if you want, download  the files!

App development

iScrape 0.4 drags and drops images, ignores blacklisted folders

Finally there is iScrape 0.4 with many more bugs and some new features. Please report me if you find any bugs or have any other suggestions. Some settings in preference pane are disabled since they aren´t implemented completely.

http://dl.dropbox.com/u/3588714/iScrape%200.4.zip

App development

iScrape 0.3 smarter and with backdrops

This is version 0.3 which i finished just a few minutes ago. I´m very happy about some users from various forums giving me feedback. Without any i absolutely had no inducement spending work on the app. I also think that certain guidelines (e.g. feature requests) make developing much more productive. Otherwise you just hack some stuff which doesn´t really feel good. Cause this is my first big “small” attempt to take care of project,  i sometimes fell like loosing my head within all these lines of code.. It got quite complex and confusing. I sometimes wonder why the app performing not too bad! Nevertheless i finally finished this version, cleared up some code and, well, added even more lines in a countermove. I´m happy about having spent some time on the app due to i really have lack of time due to my exams.

changelog

v. 0.3 (02/20/2011)

• Download backdrops (wallpaper fanart)

• (like posters) switch between backdrops and choose your favourite which will be

loaded first

• ui got a little more shiny (buttons, bigger tableviews)

• preferences have been extended for backdrops

• preference view is now a sheet (press CMD + ”,” )

• statusbar disappears when idle

bugfixes

• Faster recursive adding of folders • Removed bug where adding non-folders in non recursive mode was possible

Download v 0.3

Please give me feedback if you like it or NOT!

App development

FaceBookAuth 0.3 new view, progress-bar and small fixes

I rewrote the address-book view so now its similar to the left one. Since the native view is so overloaded and doesn´t show the profile picture i decided to replace it with. I also added a textfield showing the download process, which can be quite usefull because downloading informations ans profile pictures of a hundred friends or more (if you belong to this kind) takes quite a while.

I´m still not happy with how the user connects a facebook friend with an address book entry. It does not make much fun since you first have to choose the facebook friend and then the addressbook entry.  I sometimes find myself trying to connect in the opposite order which doesn´t work and even changes the connection of the current selected facebookfriend, if there is one. Somewhat counter intuitive.

I´d love to read suggestions! Please leave a comment if you have one.

Download

App development

iScrape 0.1 Scrape posters for all your movies (powered by tmdb)

Quite a while since i started to think about an application which should simplify my alldaylife. Such dumb redundant work like searching nice covers in the web, download and rename, and finally saving them to your favourite directory can be quite angering. I´m using a mede8er mediaplayer to playback all of my media stored on 2 external harddrives. Movies, podcasts and Music. Being all by yourself is just fine, you know what movies you own without having to explain or comment any of them. But imagine having many friends around you, especially women, complicates the whole situation . The problem then is to choose between all these movies where the title mostly doesnt tell anything about it at all. Many of my friends ask for a preview, a cover, to get an idea of what it´s about. I personally don´t agree with this, but understand the need of a visual impression. After scraping movies with some applications i was quite frustrated due to the interface, the bad image quality or the platform (windows) and/or the language (java). That´s why i tried myself developing a really small app without claiming great features. Reducing it to a minimum (a quite small minimum).

I decided to use tmdb.org as scraping resource due to its awesome API and its huge repertoire  of high definition images. Not theses ugly lowend pictures found at imdb or similar databases..

What it does

  • import folders (recursively or not) using drag/drop or openpanel
  • link a folder to a movie (from tmdb) manually
    • select one of the current results or search for another one
  • present a preview of the first image found on the server
  • set up preferences as the number of images to download, overwrite images …
    • rename images (folder.jpg might be useful for mediaplayer and windows users)
  • download images to the folder
    • batch whereby either the first result from imdb or, if manually set, the linked movie will be used

Todo

  • for now, you can´t select which poster to download, either all or the first x will be loaded
  • no way to define a blacklist of tokens to avoid like (subs, sample, VIDEO_TS…)
  • no overall preflight

Hope you enjoy it and submit suggestions!

Download