0
我想創建UITableView,其中一些單元格是按鈕。 幫助我,正確的做法是什麼?UITableView中的按鈕
1)我可以使用類似的東西:
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] autorelease];
}
if (indexPath.section == 1){
if (indexPath.row == 0){
UIButton* loginButton = [[UIButton alloc] initWithFrame:CGRectMake(9,1,302, 48)];
[loginButton setBackgroundImage:[UIImage imageNamed:@"LoginButton.png"] forState:UIControlStateNormal];
[loginButton setBackgroundImage:[UIImage imageNamed:@"LoginButton_pressed.png"] forState:UIControlStateSelected];
[loginButton setTitle:@"Login" forState:UIControlStateNormal];
[cell setBackgroundColor:[UIColor clearColor]];
[cell addSubview:loginButton];
[loginButton release];
}
}
但我看到那個按鈕是透明的,看起來很奇怪。
2)不使用任何UIButtons,讓我想要完全使用UITableViewCells
謝謝你們四個的關注,我很爲iOS完全新的,但我試圖讓應用無需廈門國際銀行。
。所以您不能直接分配給它這樣改變這樣的代碼
默認按鈕式將自定義所以設置類型buttonWithType :UIButtonTypeRoundedRect – 2013-02-20 07:03:24