Domanda

L'UITabBarController non consente orientamento orizzontale. Così ho usato una sottoclasse di UITabBarContoller (chiamato RotatingTabBarController). Il suo unico scopo è di consentire la rotazione con il ritorno SÌ alla chiamata shouldAutorotateToInterfaceOrientation.

Il problema è che quando si ruota l'iPhone nel simulatore dà il seguente errore malloc.

malloc: *** error for object 0x3888000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

Sto usando 3.0 SDK con Xcode 3.2 su Snow Leopard. Ho impostato un punto di interruzione in malloc_error_break ma non posso risalire al mio codice. C'è qualcosa che posso fare per rendere questo errore andare via?

Questa è la classe RotatingTabBarController:

#import <UIKit/UIKit.h>
@interface RotatingTabBarController : UITabBarController {
}
@end 

@implementation RotatingTabBarController
-(BOOL)shouldAutorotateToInterfaceOrientation:UIInterfaceOrientation)interfaceOrientation {
    return YES;
}
@end

Aggiornamento:

ho provato la stessa cosa con una categoria. Ma dà lo stesso errore malloc.

// UITabBarController+Rotation.h
@interface UITabBarController (rotation)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
@end

// UITabBarController+Rotation.m
#import "UITabBarController+Rotation.h"

@implementation UITabBarController (rotation)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
   return YES;
}
@end

Backtrace

[Session started at 2009-09-05 12:13:19 -0400.]
Untitled(992,0xa06d9500) malloc: *** error for object 0x2024000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Untitled(992,0xa06d9500) malloc: *** error for object 0x2014000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

[Session started at 2009-09-05 12:13:27 -0400.]
GNU gdb 6.3.50-20050815 (Apple version gdb-1344) (Fri Jul  3 01:19:56 UTC 2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".Attaching to process 992.
sharedlibrary apply-load-rules all
(gdb) bt
#0  0x951908fa in mach_msg_trap ()
#1  0x95191067 in mach_msg ()
#2  0x30244d62 in CFRunLoopRunSpecific ()
#3  0x30244628 in CFRunLoopRunInMode ()
#4  0x32044c31 in GSEventRunModal ()
#5  0x32044cf6 in GSEventRun ()
#6  0x309021ee in UIApplicationMain ()
#7  0x00002608 in main (argc=1, argv=0xbfffef94) at /Users/vishwas/Desktop/Untitled/main.m:13
(gdb) 
È stato utile?

Soluzione

Questo è un bug in iPhone SDK 3.0. E 'fissato in iPhone SDK 3.1

Altri suggerimenti

Subclassing UITabBarController non è un metodo consigliato per ottenere la rotazione dell'interfaccia. In realtà la documentazione di Apple dice rigorosamente non alla sottoclasse né UITabBarController o UINavigationController. Si dice anche che in ordine per UITabBarController per sostenere autorotazione, tutti i controllori 'gestiti' da essa deve sostenere questo orientamento (cioè paesaggio in questo caso).

Questo errore si presenta come qualcosa è o di essere rilasciati senza un alloc / init, o è in fase di doppia rilasciato, non sembra un errore nel vostro sub-classificare o codice.

Mi piace l'approccio categoria di Kevlar per risolvere il problema, è creativa, semplice, e dovrebbe funzionare per voi.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top