我希望在出現視圖時從我的UITableview的底部動畫中獲取幻燈片。所以viewDidAppear了Methode裏面我創建了下面的動畫UITableViewCell中的UIButton在動畫顯示時從側面滑入UITableView
[UIView animateWithDuration:10.0f // for testing purposes big value
delay:0.0f
usingSpringWithDamping:0.7f // 0...1
initialSpringVelocity:0.0f
options:UIViewAnimationOptionCurveEaseOut
animations:^{
[tv_team setAlpha:1.0f];
tv_teamsVerticalConstraint.constant = 0;
[self.view layoutIfNeeded];
}
completion:^(BOOL finished) {
}
];
該工程爲UITableView的本身完全沒有問題,但是我動態標籤和按鈕添加到每個UITableViewCell中,像這樣
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"teamCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
//if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
//}
[cell.contentView setBackgroundColor:[[ColorSchema sharedColorSchema] color_background]];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
UIView *vw_centered = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 480, 70)];
vw_centered.autoresizingMask = (
UIViewAutoresizingFlexibleTopMargin |
UIViewAutoresizingFlexibleBottomMargin |
UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleRightMargin
);
[vw_centered setBackgroundColor:[[ColorSchema sharedColorSchema] color_darkerbackground]];
[vw_centered.layer setCornerRadius:5.0f];
[vw_centered setTag:1];
//... more Labels
// Button to change the teamMembers
UIButton *btn_setPlayers = [UIButton buttonWithType:UIButtonTypeCustom];
btn_setPlayers.frame = CGRectMake(340.0, 39.0, 120.0, 19.0);
[btn_setPlayers setBackgroundColor:[[ColorSchema sharedColorSchema] color_darkgray]];
[btn_setPlayers setTag:indexPath.row];
[btn_setPlayers.titleLabel setFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:9.0]];
[btn_setPlayers setTitleColor:[[ColorSchema sharedColorSchema] color_orangeSolid] forState:UIControlStateNormal];
[btn_setPlayers setTitle:@"Change Team Members" forState:UIControlStateNormal];
[btn_setPlayers addTarget:self action:@selector(changeTeamMembers:) forControlEvents:UIControlEventTouchUpInside];
[btn_setPlayers.layer setCornerRadius:5.0f];
[vw_centered addSubview:btn_setPlayers];
[cell.contentView addSubview:vw_centered];
return cell;
}
問題是,在創建的按鈕從左側滑入,直到它到達第二,第三,...單元的幀位置(不是第一個 - 可能是因爲那是原型單元格)
如何停止該動畫?
進出口運行的Xcode 6個IOS 8.1
嗨。我用你的代碼做了一個簡單的項目,但沒有看到它。它可能與單元格的初始大小有關。我建議你製作一個帶有所有內部視圖的筆尖的自定義單元,並使用自動佈局。它更清潔並且可以防止錯誤,此外,您還可以在「awakeFromNib」中設置屬性,如顏色和樣式。嘗試一下... – oren