Ios UIScrollview中的iAction>;子视图
真的希望你能帮助我!我对子视图有一个奇怪的问题。我正试图在我的一个子视图中执行一个简单的iAction,但只要我单击我的按钮,它就会给我一些内存错误。我试图将其添加到属性中并合成按钮 我得到了一个用于水平滚动的滚动视图,添加了一个子视图用于垂直滚动,第二个子视图在我的按钮所在的位置放置了一个viewcontroller 如果我点击那个按钮,我会得到一个错误的访问。NSZombie给了我这个错误: 2012-04-05 14:26:06.924 SlideAppTest[44978:f803]* -[SubSlide1Hoofdstuk3 performSelector:withObject:withObject:]:消息发送到解除分配的实例0x6c4bfe0 这是我的代码: //RootSlideHoofdstuk3.h(垂直滚动) //子幻灯片1hoofdstuk3.h(幻灯片视图控制器)Ios UIScrollview中的iAction>;子视图,ios,xcode,ios5,uiscrollview,subview,Ios,Xcode,Ios5,Uiscrollview,Subview,真的希望你能帮助我!我对子视图有一个奇怪的问题。我正试图在我的一个子视图中执行一个简单的iAction,但只要我单击我的按钮,它就会给我一些内存错误。我试图将其添加到属性中并合成按钮 我得到了一个用于水平滚动的滚动视图,添加了一个子视图用于垂直滚动,第二个子视图在我的按钮所在的位置放置了一个viewcontroller 如果我点击那个按钮,我会得到一个错误的访问。NSZombie给了我这个错误: 2012-04-05 14:26:06.924 SlideAppTest[44978:f803]*
看起来您的问题不在UIButton中,而在UIScrollView中。如果将属性声明为弱属性,则该属性应为强属性(如果不尝试使用ARC,则为保留)请尝试以下操作:@property(强,非原子)IBUIButton*按钮;谢谢你的回复,我仍然收到相同的错误:(我添加了我的示例项目,如果你必须快速查看,那将非常好!谢谢我正在查看你的代码,它正在下载……嘿,伙计,恭喜……)上传代码。。。。!!!谢谢你的回复,我尝试了两个选项,strong和retain选项,两个选项都不起作用。。我用一个项目文件更新了我的帖子,也许你可以快速看看这里出了什么问题?那太好了!
#import <UIKit/UIKit.h>
@interface RootSlideHoofdstuk3 : UIViewController
<UIScrollViewDelegate>
{
}
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@end
#import "RootSlideHoofdstuk3.h"
#import "SubSlide1Hoofdstuk3.h"
@implementation RootSlideHoofdstuk3
@synthesize scrollView = _scrollView;
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (void)viewDidLoad
{
[super viewDidLoad];
_scrollView.pagingEnabled = YES;
_scrollView.contentSize = CGSizeMake(_scrollView.frame.size.width,_scrollView.frame.size.height);
_scrollView.showsHorizontalScrollIndicator = NO;
_scrollView.showsVerticalScrollIndicator = NO;
_scrollView.scrollsToTop = NO;
_scrollView.bounces = NO;
_scrollView.delegate = self;
SubSlide1Hoofdstuk3 *subslide1 = [[SubSlide1Hoofdstuk3 alloc] init];
CGRect frame = self.view.frame;
frame.origin.x = 0;
frame.origin.y = 0;
subslide1.view.frame = frame;
[_scrollView addSubview:subslide1.view];
}
#import <UIKit/UIKit.h>
@interface SubSlide1Hoofdstuk3 : UIViewController {
UIButton *button;
}
@property (nonatomic, retain) IBOutlet UIButton *button;
@end
#import "SubSlide1Hoofdstuk3.h"
@implementation SubSlide1Hoofdstuk3
@synthesize button = _button;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
}
-(IBAction)buttonActie {
NSLog(@"Button clicked!");
}
- (void)viewDidUnload
{
[super viewDidUnload];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}