在的UITabBarController不允许横向。所以我用UITabBarContoller的一个子类(称为RotatingTabBarController)。其唯一的目的它通过返回YES以shouldAutorotateToInterfaceOrientation呼叫允许转动。

的问题是,当你在模拟器旋转iPhone它提供了以下的malloc错误。

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

我使用3.0 SDK与雪豹的Xcode 3.2。我设置malloc_error_break一个断点,但我不能追溯回我的代码。 有什么我可以做,使这个错误消失?

下面是RotatingTabBarController类:

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

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

<强>更新

我试图与一个类别相同。但它给相同的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

<强>回溯

[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) 
有帮助吗?

解决方案

这是在iPhone SDK 3.0中的错误。它被固定在iPhone SDK 3.1

其他提示

子类的UITabBarController不是推荐的方式来获得界面转动。事实上苹果的文档严格说不能继承任何的UITabBarController UINavigationController的或。 它还说,为了让的UITabBarController支持自动旋转,所有控制器“管理”由它必须支持这个方向(即景观在这种情况下)。

这是错误看起来像是要么被释放没有分配/ init或它被双释放,不像你的子类或代码中的错误。

我喜欢芳纶的类的方法来解决你的问题,它的创意,简单,并应为你工作。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top