3
오늘 iOS8에서보기 위젯을 만드는 법을 배우기 시작했습니다. 확장을위한 새로운 대상을 만들었습니다. 다음 단계는 기본 viewcontroller
및 클래스를 삭제하고 새로운 UITableViewController
을 작성했으며 해당 메소드입니다.iOS8 오늘보기 위젯이 UITableViewController를 표시하지 않음
#import "TableViewController.h"
#import <NotificationCenter/NotificationCenter.h>
@interface TableViewController() <NCWidgetProviding>
{
NSArray *nameArray;
}
@end
@implementation TableViewController
- (void)viewDidLoad {
[super viewDidLoad];
nameArray = [[NSArray alloc]initWithObjects:@"joey",@"jack",@"jill", nil];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 3;
}
- (void)widgetPerformUpdateWithCompletionHandler:(void (^)(NCUpdateResult))completionHandler {
completionHandler(NCUpdateResultNewData);
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
cell.textLabel.text = [nameArray objectAtIndex:indexPath.row];
return cell;
}
가 나는 또한 freeform
에 테이블의 크기를 변경하고 300 픽셀로 높이를 설정 : 나는 다음을 구현했습니다. 그러나 나는 그 대가로 아무것도 얻지 못한다. 위젯이 비어 있습니다.
고마워요 톰! 매우 정확하고 유용한 답변. – user3687