我已經在.h文件中聲明瞭UITableView。我在表視圖5部分,現在我需要設置tableview.editing =只爲第4節如何設置編輯是在iPhone的特定部分是的
是我怎麼能顯示部分4旁邊的+
按鈕,並有所有其他部分的編輯= NO?
myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0,0,320,415) style:UITableViewStyleGrouped];
myTableView.delegate = self;
myTableView.dataSource=self;
[myTableView setSectionFooterHeight:0];
[myTableView setSectionHeaderHeight:15];
[myTableView setSeparatorColor:[UIColor lightGrayColor]];
myTableView.backgroundColor = [UIColor colorWithRed:0.85546875 green:0.8828125 blue:0.92578125 alpha:1];
[myView addSubview: myTableView];
I tried like this it is not working.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if(section==0)
{
myTableView.editing = NO;
myTableView.allowsSelectionDuringEditing = NO;
return 3;
}
else if(section ==1)
{
myTableView.editing = NO;
myTableView.allowsSelectionDuringEditing = NO;
return 2;
}
else if(section==4)
{
myTableView.editing = YES;
myTableView.allowsSelectionDuringEditing = YES;
if(isEdit == YES)
{
if([editObject.contactList count]>0)
{
return [editObject.contactList count]+1;
}
else
{
return 1;
}
}
else if(isEdit == NO)
{
if([addContactList count]>0)
{
return [addContactList count]+1;
}
else
{
return 1;
}
}
}
else if(section==2)
{
myTableView.editing = NO;
myTableView.allowsSelectionDuringEditing = NO;
return 1;
}
else if(section==3)
{
myTableView.editing = NO;
myTableView.allowsSelectionDuringEditing = NO;
return 1;
}
return 0;
}
我得到的第4節的+
按鈕,但所有其他部分被移動到右側。
非常感謝你 – 2010-05-19 12:15:10
這是很明顯的,但也確保你已將allowedSelectionDuringEditing屬性設置爲true。您可以在代碼或xib設計器中執行此操作。 更多詳細信息,請訪問:http://developer.apple.com/iphone/library/documentation/uikit/reference/UITableView_Class/Reference/Reference.html#jumpTo_4 – Helephant 2010-06-01 18:30:35