0
我使用IC卡創建了覆蓋流效果,但我已經添加了兩個按鈕,而不是通過程序在xib中,我定義了插座和動作並連接了這些按鈕......但這些按鈕顯示爲圖像而不是工作...這是我在.m文件代碼在xib中定義的方法沒有工作關閉
@interface GoldViewController()<UIActionSheetDelegate>
@property (nonatomic, assign) BOOL useButtons;
@end
@implementation GoldViewController
@synthesize carousel1;
-(IBAction)showhome:(id)sender{
ViewController *sec=[[ViewController alloc]initWithNibName:Nil bundle:Nil];
sec.modalTransitionStyle=UIModalTransitionStyleCoverVertical;
[self presentModalViewController:sec animated:YES];
}
-(IBAction)showback:(id)sender{
CollectionsViewController *sec=[[CollectionsViewController alloc]initWithNibName:Nil bundle:Nil];
sec.modalTransitionStyle=UIModalTransitionStyleCoverVertical;
[self presentModalViewController:sec animated:YES];
}
#pragma mark -
#pragma mark View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
carousel1.type = iCarouselTypeCylinder;
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
- (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel
{
return NUMBER_OF_ITEMS;
}
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
{
UIImage *buttonImage=[NSArray arrayWithObjects:[UIImage imageNamed:@"ban.jpg"],
[UIImage imageNamed:@"pen.jpg"],
[UIImage imageNamed:@"ear1.jpg"],
[UIImage imageNamed:@"neck.jpg"],
[UIImage imageNamed:@"brac.jpg"],
[UIImage imageNamed:@"rings.jpg"],nil];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0, 0, 250.0f, 320.0f);
[button setImage:(UIImage*)[buttonImage objectAtIndex:index] forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside];
return button;
}
- (CGFloat)carouselItemWidth:(iCarousel *)carousel
{
return ITEM_SPACING;
}
- (BOOL)carousel:(iCarousel *)_carousel shouldSelectItemAtIndex:(NSInteger)index
{
if (index == carousel1.currentItemIndex)
{
NSLog(@"Should select current item");
}
else
{
NSLog(@"Should select item number %i", index);
}
return YES;
}
- (void)carousel:(iCarousel *)_carousel didSelectItemAtIndex:(NSInteger)index
{
if (index == carousel1.currentItemIndex)
{
//note, this will only ever happen if useButtons == NO
//otherwise the button intercepts the tap event
NSLog(@"Did select current item");
}
else
{
NSLog(@"Did select item number %i", index);
}
}
@end
所以,如果你在兩個「IBAction」方法中設置了一個斷點,它們是否會被觸發?我看到你正在給「'buttonTapped:'」選擇器分配一個動作,但我沒有看到你創建兩個「其他」按鈕的位置(或者分配他們的動作)。我們是否缺少更多的代碼? –
他們是按鈕輕按功能,但其執行單獨的行動爲按鈕在coverflow..do我必須定義兩個按鈕的動作,我在xib按鈕輕按下定義? – Dany
如果我定義,在它的投擲預期的表達,但所有相關的表達式都可以。 – Dany