NSMutableArray를 후자를 삽입 할 개체로 사용하십시오.
int numberofrows;
NSMutableArray *objectsToDisplay;
UITableView *tbleView;
그냥 아래로 간단한 테이블보기했다 : -
- (void)viewDidLoad
{
tbleView=[[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 400) style:UITableViewStylePlain];
tbleView.delegate=self;
tbleView.dataSource=self;
objectsToDisplay=[[NSMutableArray alloc] initWithObjects:@"A ",@"B",@"C",@"D",@"E",@"F",@"G",@"H",@"I",@"J",@"K",@"L",@"M",@"N",@"O",@"P",@"Q",@"R",@"S",@"T",@"U",@"V",@"W",@"X",@"Y",@"Z",nil];
numberofrows=[objectsToDisplay count];
[self.view addSubview:tbleView];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return numberofrows;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *mycell=[tbleView dequeueReusableCellWithIdentifier:@"cellIdentifier"];
if (mycell==nil) {
mycell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cellIdentifier"];
}
mycell.textLabel.text=[objectsToDisplay objectAtIndex:indexPath.row];
return mycell;
}
는 매 5 인덱스 사용 후이 방법
를 행을 삽입하기를
-(IBAction)InsertAdvertizes:(id)sender
{
for (int i=4;i<numberofrows;i=i+5) {
[objectsToDisplay insertObject:@"Hello I am Advertize" atIndex:i];
}
NSLog(@"object is %@",objectsToDisplay);
[tbleView reloadData];
}
는
당신 테이블 같은 것을 모양 아래 표시된 이미지 : ---
감사합니다. 정말 포괄적 인 대답입니다. 한 가지 다른 점은, 만약 내가 5 개 이하의 항목을 포함하는 섹션에서 tableview를 나눠서 그들 사이에 광고를 삽입했다면 가능하다는 것인가? row.If 당신의 얼마나 많은 간격 후 (jQuery과 *)있는 tableView { 반환 <데이터 소스가 5로 나눌 수 있습니다 횟수>} –
: - (NSInteger) numberOfSectionsInTableView : 그래서 기본적으로 내가 좋아하는 뭔가를 것 추가하고 싶습니다 섹션으로 광고하십시오 헤더? 가능합니다.귀하의 코멘트와 재 장전 테이블에 설명 된 바와 같이 섹션 번호를 전달하십시오. – Warewolf
헤더의 섹션 통과 제목과 함께 섹션 헤더로 광고를 표시합니다. – Warewolf