質問

UITabBarController では横向きは許可されません。そこで、UITabBarContoller のサブクラス (RotatingTabBarController と呼ばれる) を使用しました。その唯一の目的は、 shouldAutorotateToInterfaceOrientation 呼び出しに YES を返すことで回転を許可することです。

問題は、シミュレータで iPhone を回転すると、次の malloc エラーが発生することです。

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

Snow Leopard で Xcode 3.2 で 3.0 SDK を使用しています。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は、インタフェース回転を得るために推奨される方法ではありません。実際には、Appleのドキュメントには、厳密にUITabBarControllerやUINavigationControllerのどちらかをサブクラス化していないと言います。 また、サポートオートローテーションにUITabBarControllerためには、それによって「マネージドのすべてのコントローラは、この向き(この場合はすなわち横)をサポートしなければならないと述べています。

、あなたのサブクラス化やコードのエラーのように見えません。

何かのようにそのエラー・ルックスは、いずれかのalloc / initをせずに解放されている、またはそれは二重のリリースされています

はケブラーのカテゴリーアプローチのように、私はあなたの問題を解決するために、それは創造的な、シンプルだし、あなたのために働く必要があります。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top