我有两张桌子的视图。我使用两个不同的控制器而不是文件的所有者来处理这些表中的每一个。应用程序正确加载,但是当我滚动“Under Featured”/ Store表时,会抛出EXC_BAD_ACCESS。看来桌子没有保留。我一直在上网阅读,但无法找到原因。
XIB:
UnderFeaturedViewController.h:
#import <UIKit/UIKit.h>
#import "iMagsAppDelegate.h"
@interface UnderFeaturedViewController : UIViewController <UITabBarDelegate, UITableViewDelegate, UITableViewDataSource>
{
IBOutlet UITableView *showTableView;
IBOutlet UITabBarItem *hotButton;
IBOutlet UITabBarItem *allButton;
IBOutlet UITabBarItem *catButton;
UIPopoverController *popoverController;
NSMutableArray *showArray;
iMagsAppDelegate *appDelegate;
UIInterfaceOrientation orientation;
}
@property (nonatomic, retain) IBOutlet UITableView *showTableView;
@property (nonatomic, retain) IBOutlet UITabBarItem *hotButton;
@property (nonatomic, retain) IBOutlet UITabBarItem *allButton;
@property (nonatomic, retain) IBOutlet UITabBarItem *catButton;
@property (nonatomic, retain) UIPopoverController *popoverController;
@property (nonatomic, retain) NSMutableArray *showArray;
@property (nonatomic, retain) iMagsAppDelegate *appDelegate;
-(void) setTitle:(NSString *)title;
-(void) setGuest;
-(void) updateView:(NSNotification *)notification;
-(void) dismissModalView:(int) modalID;
-(Boolean) isGuest;
-(IBAction) showTag:(NSString*)tag;
-(IBAction) showName:(NSString *) name;
-(IBAction) showStore;
-(IBAction) showOwned;
-(IBAction) showCategories;
-(IBAction) showSearch;
-(IBAction) showMore;
-(IBAction) showFirstDialog;
@end
的cellForRowAtIndexPath:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
NSInteger section = [indexPath row];
cell.textLabel.text = [NSString stringWithFormat:@"%d", section];
return cell;
}
僵尸:
回溯:
#0 0x0182509b in objc_msgSend ()
#1 0x005afd18 in -[UIScrollView(UIScrollViewInternal) _scrollViewWillBeginDragging] ()
#2 0x005a31e9 in -[UIScrollView _updatePanGesture] ()
#3 0x005a74e6 in -[UIScrollView handlePan:] ()
#4 0x0081be39 in _UIGestureRecognizerSendActions ()
#5 0x0081b143 in -[UIGestureRecognizer _updateGestureWithEvent:] ()
#6 0x0081c3cf in -[UIGestureRecognizer _delayedUpdateGesture] ()
#7 0x0081ea31 in ___UIGestureRecognizerUpdate_block_invoke_0541 ()
#8 0x0081e98c in _UIGestureRecognizerApplyBlocksToArray ()
#9 0x008173e7 in _UIGestureRecognizerUpdate ()
#10 0x0057f812 in -[UIWindow _sendGesturesForEvent:] ()
#11 0x0057fba2 in -[UIWindow sendEvent:] ()
#12 0x00566384 in -[UIApplication sendEvent:] ()
#13 0x00559aa9 in _UIApplicationHandleEvent ()
#14 0x017f5fa9 in PurpleEventCallback ()
#15 0x016361c5 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#16 0x0159b022 in __CFRunLoopDoSource1 ()
#17 0x0159990a in __CFRunLoopRun ()
#18 0x01598db4 in CFRunLoopRunSpecific ()
#19 0x01598ccb in CFRunLoopRunInMode ()
#20 0x017f4879 in GSEventRunModal ()
#21 0x017f493e in GSEventRun ()
#22 0x00557a9b in UIApplicationMain ()
#23 0x00001e5d in main (argc=1, argv=0xbffff5f0) at ...
答案 0 :(得分:0)
因此SplitViewController是文件的所有者,它保留视图但不保留UnderFeaturedViewController
为UnderFeaturedViewController创建一个强大/保留引用IBOutlet,以便SplitViewController保留它。
我认为问题是UnderFeaturedViewController没有在任何地方保留,所以它会在下一个运行循环中被释放。
您还可以在dealloc
上设置一个断点,以便了解它何时被解除分配。