2013-04-05 5 views
0

UICollectionView에 표시 할 수있는 LocalNotification을 설정하고 싶습니다. 그러나 UITable에 표시하는 방법 만 알고 있습니다. UITable에서 UIcollectionview로 변환하려면 어떻게해야합니까? UIcollectionview에 배경 이미지가있는 동안 UIlabel에 시간과 날짜를 표시하고 싶습니다.UIcollectionView에 LocalNotification 표시

다음은 로컬 알림을 사용하여 UITable을 작성하는 코드입니다.

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    // Return the number of notifications 
    return [[[UIApplication sharedApplication] scheduledLocalNotifications] count]; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    static NSString *CellIdentifier = @"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; 
    } 
    cell.textLabel.textColor = [UIColor whiteColor]; 

    // Get list of local notifications 
    NSArray *notificationArray = [[UIApplication sharedApplication] scheduledLocalNotifications]; 
    UILocalNotification *notif = [notificationArray objectAtIndex:indexPath.row]; 

    // Display notification info 
    [cell.textLabel setText:notif.alertBody]; 


    return cell; 
} 
+0

무엇을 시도 했습니까? 컬렉션 뷰의 API는 테이블 뷰의 API와 매우 유사합니다. – rdelmar

답변

0

표보기와 모음보기 모두 셀을 사용하여 내용을 표시합니다. 일단 콜렉션 뷰가 있으면 여기에 표시된 두 개의 연산 (행의 수를 결정하고 행의 셀에 텍스트를 채우는 것)은 콜렉션 뷰와 동일합니다.

자습서를 따라 컬렉션 뷰를 만든 다음 numberOfItemsInSection 및 cellForItemAtIndexPath :를보고 위에있는 메소드와 비교하십시오. tableView : numberOfRowsInSection : verbatim의 코드를 사용할 수 있어야하며 코드 사소한 변화가있는 다른 방법에 대해서.

관련 문제