Pergunta

O UitabBarController não permite a orientação da paisagem. Por isso, usei uma subclasse do UITABBARCONTOLLER (chamado RotatingTabBarController). É o seu único objetivo permitir a rotação retornando sim à chamada deve ser interna.

O problema é que, quando você gira o iPhone no simulador, ele fornece o seguinte erro do MALLOC.

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

Estou usando o 3.0 SDK com o Xcode 3.2 no Snow Leopard. Definei um ponto de interrupção em Malloc_error_break, mas não posso rastreá -lo de volta ao meu código. Existe algo que eu possa fazer para fazer esse erro desaparecer?

Aqui está a classe RotingTabBarController:

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

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

Atualizar:

Eu tentei o mesmo com uma categoria. Mas dá o mesmo erro 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) 
Foi útil?

Solução

Este é um bug no iPhone SDK 3.0. Está corrigido no iPhone SDK 3.1

Outras dicas

A subclasse UitabBarController não é uma maneira recomendada de obter rotação de interface. De fato, a documentação da Apple diz estritamente para não subclasse UITABBARCONTROLLER ou UINAVUGATIONCONTROLLER. Ele também diz que, para que o UitabBarController apoie a autorotação, todos os controladores 'gerenciados' devem apoiar essa orientação (ou seja, cenário neste caso).

Esse erro parece que algo está sendo lançado sem um aloc/init ou está sendo lançado duplo, não parece um erro na sua subclassificação ou código.

Eu gosto da abordagem da categoria de Kevlar para resolver seu problema, é criativo, simples e deve funcionar para você.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top