Info

Magnus Eriksson, Developer at Vaimo, a web agency heavily into Magento. Doing alot of coding in my spare time.

Posts tagged Iphone

Choose another tag?

There is a problem with adding files with extension .a to subversion. extension .a is compilated code in objective-c and there for useful to add to svn, mostly if you are group of developers so they can compile the checked out code. The reason it cant be added is because it exists in the global ignore list. You can change it if you want through the terminal, i guess it exist there for a reason so i have not done this.

The way i do it is by renaming it prior to adding, like codeexample.rename, add it, commiting, then use the svn rename and rename it back to .a. Now you can commit the changes and voilá, it exist in your repository.

Commands are from the swedish keyboard layout.

Auto Indent: ctrl + I
Comment on mouse selects: apple + shift + 7 (/)

Kalle Persson came up with these tips in the comments.

Switching between. M and. H file: ctrl + cmd + arrow up
Force autocompletion: esc
Switching focus between the panels: cmd + j

Thanks to Kalle, if you want to tell about more great commands, add a comment.

 

Here are two suggestions how to solve a horizontal view, that is, a view that differs from the vertical.

Either make it a modal with a risk that it takes ”time” until it appears, the transition can be a bit slow.

.h

@interface XXXX : UIViewController
{
    BOOL isShowingLandscapeController;
}

@property (nonatomic) BOOL isShowingLandscapeController;

.m

- (void)viewDidLoad
{
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:)  name:UIDeviceOrientationDidChangeNotification object:nil];  
}

-
(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) orientation {
    return (orientation == UIInterfaceOrientationPortrait);
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
    [super dealloc];  
}

- (void)orientationChanged:(NSNotification
*)notification
{
    [self performSelector:@selector(updateLandscapeView) withObject:nil afterDelay:0];
}

- (void)updateLandscapeView
{
    UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
    if (UIDeviceOrientationIsLandscape(deviceOrientation) && !isShowingLandscapeController)
    {
         UIViewController viewController = [[UIViewController alloc] initWithNibName:nil bundle:nil];
         [self presentModalViewController:viewController animated:YES];
     [[UIApplication sharedApplication] setStatusBarOrientation: deviceOrientation];
         isShowingLandscapeController = YES;
     [viewController release];
   } else if (UIDeviceOrientationIsPortrait(deviceOrientation) && isShowingLandscapeController) {
         [self dismissModalViewControllerAnimated:YES];
         isShowingLandscapeController = NO;
   }
}

You can also choose to do in a different way and it is to use dual views, a tip is to only load what is visible but the code is not included in the example.

.h

@interface XXXX : UIViewController
{
    UIViewController *viewPortrait;
    UIViewController *viewLandscape;
}

@property (nonatomic,assign) UIViewController *viewPortrait;
@property (nonatomic,assign) UIViewController *viewLandscape;

.m

- (void)loadView {
    viewPortrait = [[UIViewController alloc] initWithNibName:nil bundle:nil];
    viewLandscape = [[UIViewController alloc] initWithNibName:nil bundle:nil];
    viewPortrait.hidden = NO;
    viewLandscape.hidden = YES;
}

- (void)viewDidLoad
{
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];

}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) orientation {
     return (orientation == UIInterfaceOrientationPortrait);
}

- (void)dealloc
{
     [[NSNotificationCenter defaultCenter] removeObserver:self];
     [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
     [super dealloc];
}

- (void)orientationChanged:(NSNotification *)notification
{
     [self performSelector:@selector(updateLandscapeView) withObject:nil afterDelay:0];
}

- (void)updateLandscapeView
{
    UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;

    if (UIDeviceOrientationIsLandscape(deviceOrientation) )
    {
    viewPortrait.hidden = YES;
        viewLandscape.hidden = NO;
    } else if (UIDeviceOrientationIsPortrait(deviceOrientation) ) {
        viewPortrait.hidden = NO;
        viewLandscape.hidden = YES;
    }
}